Topic: How to set environment variables

Rails can't seem to find the RMagick module on my server. I've tried to set the GEM_HOME environment variable for rails with no luck.

I wrote a little .rhtml view to output all of the environment variables and only path appears (albiet for the incorrect location).

I have been unable to set environment variables and have the changes show up in the ruby script with both the apache SetEnv directive and the 'rake environment GEM_HOME=whatever' command

Any ideas on how I can set the environment variables? (or at least how I can get it to find the RMagick module)

Re: How to set environment variables

Have you tried setting it in the config/enviroment.rb file?

Railscasts - Free Ruby on Rails Screencasts

Re: How to set environment variables

Hmm that didn't seem to change any of them.

Perhaps my environment outputting action is wrong, but the view is just:

<% ENV.each do |key, value| %>
<p><%= key %> => <%= value%></p>
<% end %>

Re: How to set environment variables

Have you tried setting it like this?

# environment.rb
ENV['GEM_HOME'] = '/path/to/gems'

I believe it should go before Rails::Initializer.

Also, don't forget to restart the server.

Last edited by ryanb (2006-07-29 23:31:51)

Railscasts - Free Ruby on Rails Screencasts