Search code examples
ruby-on-railsapachepassengersetenv

Phusion Passenger 4 ignores setenv GEM_PATH


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.


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.