Question

I wanted to (finally) update my Passenger install from version 3 to 4, but I'm having some trouble setting the GEM_PATH env variable as I did with v3.

In my Apache configuration I have the following line, telling passenger where to find my rvm gemsets (note @my_set):

SetEnv GEM_PATH "/.../.rvm/gems/ruby-1.9.3-p448@my_set:/.../.rvm/gems/ruby-1.9.3-p448@global"

This works fine with Passenger v3. However when I switch to version 4, the application fails to load and the debug view shows the following:

GEM_PATH = /.../.rvm/gems/ruby-1.9.3:/.../.rvm/gems/ruby-1.9.3-p448@global

Which seems to be the system default.

Setting any other ENV variable using setenv works. For example I added the line

SetEnv TEST_VAR "FOO"

to my apache configuration and it turned up in the passenger debug view without a hitch:

TEST_VAR = "FOO"

It feels like Passenger is specifically overwriting my GEM_PATH environment variable somehow. There's no mention of this in the docs as far as I can tell. Any thoughts would be greatly appreciated.

Was it helpful?

Solution

You can do this one other way. Since you are using Rails in version 3 or 4 with bundler, you can make bundler isolate all gems for application on a production server putting copies of them into application folder. To do that issue:

bundle install --deployment

You can read more about it in Bundler Deployment documentation

You can also read up on how to make RVM work with Passenger 3 (it might be transferrable to 4) with gemsets, though in my opinion, using bundler deployment is much better option.

OTHER TIPS

I am not sure it will help you but, instead of considering the GEM_PATH, maybe you should consider the PassengerRuby and the PassengerDefaultRuby configuration http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerRuby

Passenger is certainly trying to use the default ruby of your system, and you have to tell it to use the good one, that is to say the one yuo installed with RVM. To find the correct ruby, in your console, be sure that the ruby you are using is the one you want to use, you can type

ruby -v
which ruby
rvm list
rvm use [the one you want to use]

Once you are sure that in this terminal session, the ruby you are using is the on you want passenger to use, type this command

passenger-config about ruby-command

You should then see a line like :

To use in Apache: PassengerRuby /home/tommyjam/.rvm/gems/ruby-2.1.1/wrappers/ruby

Copy the interesting information and paste it in the good location, that is to say, as the passenger doc say

PassengerRuby may occur everywhere: in the global server configuration, in <VirtualHost>, in <Directory>, in <Location>, and in .htaccess if AllowOverride Options is on

You can also change PassengerRuby to PassengerDefaultRuby and put it in the global server configuration, which is, I think in the /etc/apache2/mods-available/passenger.conf

Hope it will help you :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top