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?

link|improve this question

feedback

2 Answers

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.

link|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
feedback

I know this is an old thread, but incase anyone else is having this problem just install RVM (http://rvm.beginrescueend.com/) 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!

B

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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