<p>I've set up Passenger in development (Mac OS X) and it works flawlessly. The only problem came later: now I have a custom <code>GEM_HOME</code> path and ImageMagick binaries installed in <code>"/usr/local"</code>. I can put them in one of the shell rc files that get sourced and this solves the environment variables for processes spawned from the console; but what about Passenger? The same application cannot find my gems when run this way.</p>

[{'answer_id': 79615, 'author': 'Brian Phillips', 'author_id': 7230, 'author_profile': 'https://Stackoverflow.com/users/7230', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ve run into this issue as well.  It <a href="http://groups.google.com/group/phusion-passenger/browse_thread/thread/79474d37028f2a03" rel="nofollow noreferrer">appears</a> that Passenger doesn\'t passthrough values set using the <code>SetEnv</code> apache directive - which is unfortunate.</p>\n\n<p>Perhaps it might be possible to set environment variables in your environment.rb or boot.rb (assuming you\'re talking about a Rails app; I\'m not familiar with Rack but presumably it has similar functionality)</p>\n'}, {'answer_id': 80003, 'author': 'manveru', 'author_id': 8367, 'author_profile': 'https://Stackoverflow.com/users/8367', 'pm_score': 2, 'selected': False, 'text': "<p>Before you do any requires (especially before requiring rubygems) you can do:</p>\n\n<pre><code>ENV['GEM_HOME'] = '/foo'\n</code></pre>\n\n<p>This will change the environment variable inside this process.</p>\n"}, {'answer_id': 81255, 'author': 'Ben Scofield', 'author_id': 6478, 'author_profile': 'https://Stackoverflow.com/users/6478', 'pm_score': 5, 'selected': True, 'text': '<p>I know of two solutions. The first (documented <a href="http://www.viget.com/extend/rubyinline-in-shared-rails-environments/" rel="noreferrer">here</a>) is essentially the same as manveru\'s—set the ENV variable directly in your code.</p>\n\n<p>The second is to create a wrapper around the Ruby interpreter that Passenger uses, and is documented <a href="http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/" rel="noreferrer">here</a> (look for passenger_with_ruby). The gist is that you create (and point PassengerRuby in your Apache config to) /usr/bin/ruby_with_env, an executable file consisting of:</p>\n\n<pre><code>#!/bin/bash\nexport ENV_VAR=value\n/usr/bin/ruby $*\n</code></pre>\n\n<p>Both work; the former approach is a little less hackish, I think.</p>\n'}, {'answer_id': 363314, 'author': 'Raimonds Simanovskis', 'author_id': 16829, 'author_profile': 'https://Stackoverflow.com/users/16829', 'pm_score': 2, 'selected': False, 'text': '<p>I found out that if you have root priviledges on computer then you can set necessary environment variables in "envvars" file and apachectl will execute this file before starting Apache.</p>\n\n<p>envvars typically is located in the same directory where apachectl is located - on Mac OS X it is located in /usr/sbin. If you cannot find it then look in the source of apachectl script.</p>\n\n<p>After changing envvars file restart Apache with "apachectl -k restart".</p>\n'}]
['https://Stackoverflow.com/questions/79474', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11687/']