How do I specify a version of Ruby for Rails without using RVM?

234 Views Asked by At

How do I specify a version of Ruby for Rails without using RVM?

I am using Xubuntu 11.10, which comes with Ruby 1.8. I have installed Ruby 1.9 package, and updated the alternatives so ruby -version returns ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]. Rails still seems to be using 1.8 however, so how can I tell it to use Ruby 1.9 instead? I don't want to uninstall Ruby 1.8 since that will remove a bunch of other stuff as well.

I know similar SO questions have been answered with "use RVM". I can't do this - it has a dependency on libreadline-gplv2-dev package, which conflicts with libreadline-dev which r-base-dev depends on.

3

There are 3 best solutions below

1
On

It seems I need to update the gem command to use the 1.9 version as well as ruby, then I can install rails through that. But to install rails, I need the dev headers for ruby. The following commands should work for others:

sudo apt-get install ruby1.9.1 ruby1.9.1-dev
sudo update-alternatives --config ruby
sudo update-alternatives --config gem
sudo gem install rails
0
On

It seems your rubygems environment is using ruby 1.8 whereas you want your rails app to run in 1.9. You can find out by doing this:

$ ruby -version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

$ gem env | grep 'RUBY VERSION'
   - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

Make sure your rubygems environment under which rails runs is running the version you want.

0
On

Changing versions of ruby is a routine if you work with several projects. If you can't use rvm, try rbenv.