installed ruby using apt-get install ruby 2.0.0 succeeded but not using correct ruby version
Solution 1
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
Solution 2
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.
Related videos on Youtube
Jngai1297
Updated on January 08, 2020Comments
-
Jngai1297 over 4 years
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?
-
Raúl Salinas-Monteagudo over 8 yearsCheck the link where "ruby" is pointing to. In my system I have both versions installed and /usr/bin/ruby points to the older one. ls -l $(which ruby)
-
-
Jngai1297 over 10 yearsmy friend who launched his rails app on digitalocean said I shouldn't use rvm and just install ruby on rails directly which I don't quite understand. In the mean time can you help me get apt-get install ruby to work for now?
-
mbaird over 10 yearsRVM makes installing Ruby and managing it a whole lot easier, not sure why your friend would advise against it. Anyway, the command you ran will have installed Ruby 1.9.1. As far as I know there is no Ruby 2.0.0 package, so you'll need to compile it from source. I've added instructions to my original post.
-
Jngai1297 over 10 yearsI am encountering dependencies issue and I apt-get install tons of packages and and I am unable to install rails. I emailed my friend to ask about using rvm. If I ssh into my vps server and install rvm ruby is this a system wide thing or can I lock it into my vps server only? maybe that was his reason to advise against rvm/rbenv?
-
mbaird over 10 yearsA VPS is functionally equivalent to a dedicated server. You have superuser access to that machine, which is entirely yours to do what you wish. Installing RVM won't affect anything beyond the reach of your server, and is entirely removable should you wish. In fact, looking at digitaloceans website, they have guides for installing RVM on their own servers, similar to the instructions i've posted above. Hope this helps.
-
Jngai1297 over 10 yearsok I am encountering dependencies issues with compiling by source, I will use rvm. how do I remove the compiled ruby? I am sorry about this or maybe I can reboot my vps with digital ocean/create a new server and restart over too. I am currently rebuilding my vps. Hope this works.
-
Jngai1297 over 10 yearswhen I install rails do I just do 'gem install rails' I am having trouble installing gems for my rails app in vps in linux machine. I can bundle fine with my dev machine.