Ruby 1.8 and 1.9 are installed in my Ubuntu machine. I've just installed Ruby 2.0.0 from ppa:brightbox/ruby-ng-experimental
to install a bundle which requires 2.0.0. Now all 1.8, 1.9 and 2.0 are installed though I can't tell bundle to use 2.0:
$ bundle install
$ Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
RVM fails to change version:
$ rvm 2.0
$ ruby-2.0.0-p451 is not installed.
$ To install do: 'rvm install ruby-2.0.0-p451'
RBENV also does not recognize 2.0:
$ rbenv global 2.0.0-p451
$ rbenv: version `2.0.0-p451' not installed
There is lots of advise in the comments to your question, some of it is advanced-ish rbenv or rvm usage.
My advice: Decide on how to manage multiple rubies - either use your OS package manager (in your case the apt-get
/PPA stuff) OR rvm OR rbenv.
For the OS package manager, there should be a way to call ruby with version explicitely (e.g. /usr/bin/ruby1.9.3
), or research on and call update-alternative
. As bundler comes with a gem, you might get the interpreters confused here.
For rvm, change ruby version with rvm use 2.5.1
(once it is installed).
For rbenv I actually do not know but it should be trivial, too (and people are happy with it; it just happens that I tried rvm first and it worked like a charm, never evaluated rbenv).
I usually install one "system" ruby (apt-get install ruby1.9.3) and use rvm afterwards. You can still switch to the packaged "production" ruby with rvm use system
.
Update 2017: Most distros ship with a ruby version installed already, so you probably don't have to install it manually. Run ruby -v
or which ruby
to see if a ruby interpreter is already installed.
In your case I would probably deinstall all system rubys (apt-get purge ...
), remove the PPAs, remove your ~/.rvm and rbenv and start from scratch (install packaged stable ruby, then rvm and use rvm (r.g. rvm install 2.3.1
) from there on).
Adding the repository If you’re using Ubuntu 14.04 (Trusty) or newer then you can add the package repository like this:
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
Install ruby switch
$ sudo apt-get install ruby-switch
Commands of utiliy
ruby -v
ruby-switch --list
Example
$ sudo ruby-switch --set ruby2.1
Hope this help you.
From: https://www.brightbox.com/docs/ruby/ubuntu/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With