# Setting environment variable for Rails app?

**URL:** <https://www.ruby-forum.com/t/setting-environment-variable-for-rails-app/80099>\
**Category:** Rails\
**Created:** [March 12, 2006, 4:58pm UTC](https://www.ruby-forum.com/t/setting-environment-variable-for-rails-app/80099 "2006-03-12T16:58:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [March 12, 2006, 4:58pm UTC](https://www.ruby-forum.com/t/setting-environment-variable-for-rails-app/80099/1 "2006-03-12T16:58:09Z")

</div>

Greetings! I’m trying to set an environment variable in Rails. Why? I  
can’t use RMagick unless I do so. I can do it from the shell, run  
irb, and then require ‘RMagick’ works. So far so good. But how can I  
do this from my Rails application?

I’m on a shared host so I’ve put in a ticket to have something like  
this added to httpd.conf:

SetEnv LD\_LIBRARY\_PATH /usr/local/lib

That would probably fix it. I’ve tried adding it to my .htaccess with  
the other settings but it doesn’t seem to work. Restarted the process  
and everything. Even tried adding this to environment.rb but nothing:

LD\_LIBRARY\_PATH="/usr/local/lib"

Is there any way to force this library path in my application? Or am  
I stuck waiting for my shared hosting company to figure out and fix  
the issue?

---

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [March 12, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/setting-environment-variable-for-rails-app/80099/2 "2006-03-12T18:45:24Z")

</div>

I think you can do it in environment.rb, you just didn’t do it the right  
way.

ENV[‘LD\_LIBRARY\_PATH’] = ‘/usr/local/lib’

Pat

---

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [March 13, 2006, 5:29pm UTC](https://www.ruby-forum.com/t/setting-environment-variable-for-rails-app/80099/3 "2006-03-13T17:29:52Z")

</div>

Thanks, Pat. I’ve tried setting it that way, I’ve tried setting it in  
.htaccess, I’ve even got my web host to set it in Apache’s vhost  
config for FCGI, which I’m running under.

But I’m still getting “uninitialized constant Magick” as soon as I try  
to require ‘RMagick’. Is there anything at all I might still possibly  
be missing? Or is this just a lost cause? It seems crazy to me that  
the RMagick libraries would be on the server, and accessible to irb if  
the variable is exported for the shell, but unusable to my  
application!
