Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need two different versions of ruby on a server. The packaged ruby for the packaged puppet to work, and a compiled ruby for a rails web app to work. So basically I want the default ruby to be the ruby from the package, and for rails to use the compiled ruby (in /usr/local/bin/ and /usr/local/lib/ )

I've found references to setting the RUBYPATH and RUBYLIB environment variables, but I'm confused as to where to set them. In .bashrc, .profile, in the apache config somewhere?

share|improve this question
up vote 4 down vote accepted

One trick would be to munge the PATH to include the one you want first. That is likely a hack though.

If you are using Rails 2.x (which I assume you are) you can specifically run things with a path there, such as:

/usr/local/bin/ruby script/server

(for development mode for example.)

If you are using something like Phusion Passenger, which I personally recommend, I think it can be set globally for the web server config. I am not certain if you can do it per-virtual-host using Passenger, but it doesn't sound like you need that.

share|improve this answer
+1 RUBYPATH and RUBYLIB are the wrong approach. The web server needs to know which ruby to use. RubyEE will actually build mod_rails (Passenger) for you, if I recall correctly. – Kyle Smith May 26 '10 at 10:12

I know this is an old thread, but incase anyone else is having this problem just install RVM ( You can literally switch versions of ruby that the system uses like this (at the command line):

rvm 1.9.2
ruby -v  (will display ruby 1.9.2)

rvm 1.8.7 
ruby -v (will display ruby 1.8.7)

Simple, no problems!


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.