Trying to install ruby and ruby on rails 4 on Ubuntu? - ruby-on-rails

So I'm following this guide at http://railsapps.github.io/installrubyonrails-ubuntu.html
and I install RVM without a hitch. However, when I check for the version of ruby that I installed via:
ruby -v
I got the following:
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: sudo apt-get install <selected package>
I tried to install ruby manually through RVM:
rvm install ruby
However, it merely told me that ruby had already been installed.
Has anyone encountered this same issue?
TIA

you can try with these urls these may help you for installing rvm and ruby installation and rails installation
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
This may help you

After installing rvm, if you installed it as root, try
source /etc/profile.d/rvm.sh
If you installed as user, try
source ~/.rvm/scripts/rvm

I've definitely been there. I created a script to help me install ruby on remote machines. This was made for new EC2 instances, but maybe it will work.
https://github.com/jubrad/install_ruby
If you do want to use it you'll likely have to remove rvm and your rubies first.
-https://rvm.io/rubies/removing
-sudo apt-get remove rvm
best of luck.

Related

Trying to set up Ruby Rails on Mac

Am trying to set up rails on mac using rbenv and Homebrew.
Currently getting the following message when attempting to 'gem install rails':
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
username-mbp:projects username$ gem install rails
Any ideas??
If you are using rbenv, you should not use sudo to install gems. rbenv very helpfully installs your gems under your home directory in a way that allows you to use different gems for each installed Ruby version. When you change versions of Ruby you will really appreciate this.
To see the current version of Ruby, use rbenv local. For me this prints:
2.2.2
To see all the Ruby versions on your system of which rbenv is aware:
rbenv versions
rbenv stores the version specifier in a file called .ruby-version. This allows you to use different versions of Ruby for different projects, each version having its own set of gems.
When you try to install rails and get the Gem::FilePermissionError, it means that rbenv is not active, or you are deliberately installing into the "system" Ruby. There is nothing wrong with this per se, but you are not taking advantage of rbenv.
I recommend installing Rails again, using rbenv local to ensure that you are adding the gems to the correct path. You'll know this is working when
gem env gemdir
produces something like:
/Users/username/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
See https://github.com/sstephenson/rbenv#installation for more info.
This probably means that you used sudoat some point, which means that you run a command that allows you (as a permitted user to execute a command as the superuser or another user) See here: http://linux.about.com/od/commands/l/blcmdl8_sudo.htm.
Can you please paste the commands you used for installing rbenv, ruby, gem, brew, etc.? Also please paste the output of brew doctorto see if environment is correctly configured for Homebrew. Also, please paste the OSX version and rbenv versionsif rbenv is installed.
The steps for installing ruby on rails on OSX are:
Install Homebrew by:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`` (as seen here: http://brew.sh/). Run brew doctor and brew updateto see if everything is fine.
Install ruby: OS X comes with Ruby installed (Mavericks/Yosemite even gets version 2.0.0, previously it was only 1.8.7).
Install rbenv: it can be done either by GitHub Checkout or Brew. You probably should use brew. Run brew install rbenv ruby-build(this will also install ruby-build -https://github.com/sstephenson/ruby-build#readme-). You can also use this command brew install rbenv ruby-build rbenv-gem-rehash. Then echo 'eval "$(rbenv init -)"' >> ~/.bash_profile (to enable shims and autocompletion). You should problably run this too: echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile. Close terminal and open it again. Install the preferred version of ruby (if you want): rbenv install 2.0.0-p353.
Install Bundler: gem install bundler.
Install SQLite: gem install sqlite3
Install Rails: gem install rails.
So, the error you are having is due to permissions (you can understand about them here: http://www.tutorialspoint.com/unix/unix-file-permission.htm). Many people suggest fixing the issue with sudo or chown (http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/). I don't recommend that as it messes with system configuration. It will be better that you run:
rbenv install 2.1.2
rbenv global 2.1.2
gem update --system
When I run with this error like a year ago, what I did was uninstall everything and start again... but, probably that'll take too long.
These links might help you:
ruby for mac, ruby rbenv, rbenv githube, rubies and gems, question on stack
Use sudo:
sudo gem install rails
This guide helped me a lot: Setup Ruby On Rails on
Mac OS X 10.10 Yosemite

Why do I get a requirements error when trying to install Ruby with RVM?

I would like to install Ruby 2.0 with RVM on my Ubuntu system and get an error message:
rvm 1.23.5 (master)
ubuntu 12.04 (LTS)
**---- Error message: -------**
rvm install 2.0.0
Searching for binary rubies, this might take some time.
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating system.....................................................................................................................................
Error running 'requirements_debian_update_system ruby-2.0.0-p247',
please read /home/emzett/.rvm/log/1381812161_ruby-2.0.0-p247/update_system.log
Requirements installation failed with status: 100.
Update the system using:
sudo apt-get update
Try:
rvm remove 2.0.0 # uninstall rvm
rvm get head --autolibs=3 # get the latest RVM and build required libs
rvm requirements # check if there are any dependencies that need to be installed.
rvm install ruby-2.0.0
I solved the problem by editing
etc/apt/source.list.d/medibuntu.list
I just commented the line referring to medibuntu out.
https://gist.github.com/pcjpcj2/5443017
I recommend this gist.
if you need Ruby on Rails 4.0 ~ , best answer is here
I had the same issue. I ran the following command to fix it:
sudo apt-get -f install
Then I remembered that I failed installing a package earlier that day. What this command did was resolve the dependencies on that package and allowed RVM to do its thing.
This happens when there are broken sources in /etc/apt/sources.list.d or /etc/apt/sources.list.d
You can run Ubuntu Software update to see if there are any any failures due to broken sources, if so, follow the below steps
fix them or comment and execute the following steps
rvm requirements -- this will install all of
the required software modules
rvm list -- provides you the available versions of ruby
rvm install ruby-x.x.x -- This will install x.x.x version of ruby, please change the ruby-x.x.x with the version you are interested in ex (ruby-2.1.0 for 2.1.0 version of ruby)

Remove Ruby and Rails from my system?

i got several problem runnings ruby and rails. I installed ruby via Macports. How to I remove everything and reinstall everything from the ground up?
Thanks,
To uninstall from MacPorts:
port uninstall ruby
I recommend installing rvm and using it to manage all of your ruby versions. Start here: http://rvm.beginrescueend.com/
Once you have it installed, reload your shell and type:
rvm install ruby-1.9.2
Once that is done, type
rvm use ruby-1.9.2 --default
This will replace your system ruby with the rvm 192 version. Feel free to install any other versions and switch to them using rvm list and rvm use.
For me this code worked very well sudo apt-get autoremove ruby

Installed Ruby, but installing RubyGems does not work

I just installed ruby on Ubuntu by running this command:
sudo apt-get install ruby1.9.1-full
Then I downloaded RubyGems, extracted it, and navigated to that directory. When I typed this command:
ruby setup.rb or sudo ruby setup.rb
I got this error:
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt-get install ruby
How should I invoke my Ruby installation? Should I reboot? Any ideas what the problem is?
I think your problem is twofold:
Ruby1.9 bundles rubygems by default so there is no need to install manually.
Ruby will proabably be installed as ruby1.9.1-full and you might need to rename manually to ruby. A good solution is to use rvm.
Use:
sudo ruby1.9.1 setup.rb
or
sudo ruby1.9.1-full setup.rb

no such file to load -- readline

I am getting the following error:
$script/console
Loading development environment (Rails 2.2.2)
/opt/ruby-enterprise-1.8.6-20080709/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
Where can i get the file and what directory should it go in?
Thanks!
The readline module is normally part of the Ruby package itself.
Did you manually build your Ruby install? If so, you want to make sure libreadline and its headers are installed, and build again.
On Debian/Ubuntu:
apt-get install libreadline-dev
Or on RHEL/CentOS, try
yum install readline-devel
Update:
You are using a very old release of Ubuntu. If you want to keep using it, open /etc/apt/sources.list in a text editor, and change all occurrences of archive.ubuntu.com to old-releases.ubuntu.com. Then, run apt-get update and try the above again.
I urge you to consider updating your installation, though. Ubuntu 7.10 hasn't seen security updates in quite a while, and using it in production is not recommended. Even if it's not a production machine, there's a good chance you'll run into further problems because of old versions of certain libraries/dependencies.
You need to install the ncurses and readline libraries.
On Ubunutu you could do
sudo apt-get install libreadline5-dev libncurses5-dev
and then you will have to recompile readline which comes with your ruby source
cd <ruby-src-dir>/ext/readline
ruby extconf.rb
make
sudo make install
If you are using RVM you could simply do
rvm package install readline
EDIT:
On newer RVM versions, this last command is
rvm pkg install readline
Add the following line to your Gemfile and run bundle update
gem 'rb-readline'
credits to similar question/answer at install ruby 1.9.3 using rvm on ubuntu
This easiest way to get relief from this problem,
just add to your Gemfile:
gem 'rb-readline'
And then run bundle install
Run the command
rvm requirements
It shows the requirements and dependencies. Install those and reinstall the ruby on rvm
rvm remove 1.9.2
rvm install 1.9.2
It works!
EDIT
If you can't find the requirements option update your rvm.
rvm update --head # older rvm
or use rvm upgrade
Maybe this is a bullshit answer, but I ran into this problem today after upgrading postgres from 9.5.3 to 9.6, along with which homebrew upgraded readline from 6.something to 7. I ended up rolling back my postgres to 9.5.3 and that resolved the issue.

Resources