Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installed ruby using apt-get install ruby 2.0.0 succeeded but not using correct ruby version

Hi I am really new to linux. I am currently deploying an app on digital ocean so I am switching to linux ox temporarily.

I did

sudo apt-get install ruby 2.0.0 

and installed correctly but when I do ruby-v I am getting the 1.8.7 version.

I am sure that the old version is prepackaged with mint.

How do I switch to ruby 2.0.0 in my bash profile or the linux startup files?

like image 998
Jngai1297 Avatar asked Aug 30 '13 21:08

Jngai1297


People also ask

How do I install a specific version of Ruby?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

How do I revert to a previous version of Ruby?

Go to your control panel and find the ruby or rails installer. Uninstall it. Go to your file explorer and make sure the folder is gone. Now go to http://rubyinstaller.org/downloads/ and pick an older version.


2 Answers

If you're new to linux I'd recommend using something like RVM (Ruby Version Manager) to install ruby. It makes it easier to switch ruby versions and manage multiple gemsets.

To install RVM with the latest (stable) ruby:

\curl -L https://get.rvm.io | bash -s stable --ruby

then check which rubies are installed by using

rvm list

you can then switch ruby versions using

rvm use 2.0.0 --default

with the --default flag overriding any system ruby.

Update
If you really don't want to use RVM, then use

sudo apt-get install checkinstall

wget -c http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -xzf ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0

./configure   
make

sudo checkinstall -y \
  --pkgversion 2.0.0-p0 \
  --provides "ruby-interpreter"

checkinstall will package the source, making it easier to remove in the future

You'll then need to add the Ruby binaries to your path, by editing the env file:

sudo nano /etc/environment

add /usr/local/ruby/bin

PATH="/usr/local/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

then run

source /etc/environment

to reload the file, and check your ruby version with

ruby -v
like image 100
mbaird Avatar answered Oct 01 '22 15:10

mbaird


You didn't actually install ruby 2.x.x with that apt-get command. The normal repositories have ruby 1.8 and ruby 1.9.1 in them, currently.

There shouldn't be a space in your apt-get command either. With that command you would've installed ruby 1.9.1 (which is the same thing as saying apt-get install ruby). The 2.0.0 would have been interpreted as a package name.

like image 20
jamie Avatar answered Oct 01 '22 16:10

jamie