# Environment variables problem

**URL:** <https://www.ruby-forum.com/t/environment-variables-problem/124873>\
**Category:** Rails\
**Created:** [January 3, 2008, 12:25pm UTC](https://www.ruby-forum.com/t/environment-variables-problem/124873 "2008-01-03T12:25:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [January 3, 2008, 12:25pm UTC](https://www.ruby-forum.com/t/environment-variables-problem/124873/1 "2008-01-03T12:25:49Z")

</div>

I am trying to do something that I thought would be trivial - pulling  
in a value from an environment variable.  
in my .bash\_profile I have:  
XML\_API=[http://192.168.1.5:8080/abp3/webApiXmlRpcServlet](http://192.168.1.5:8080/abp3/webApiXmlRpcServlet)

It shows up in the output of typing ‘env’ at the command prompt.  
In my environment.rb I have this:  
XML\_RPC\_LOCATION = ENV[‘XML\_API’] || ‘[http://xxxx/abp3/](http://xxxx/abp3/)  
webApiXmlRpcServlet’

From console I get:  
Loading production environment.

> > puts XML\_RPC\_LOCATION  
> > [http://192.168.1.5:8080/abp3/webApiXmlRpcServlet](http://192.168.1.5:8080/abp3/webApiXmlRpcServlet)

Which is correct.

But from inside my rails app I get:  
XML\_RPC\_LOCATION:  
[http://xxxx/abp3/webApiXmlRpcServlet](http://xxxx/abp3/webApiXmlRpcServlet)

What is going on?

The same thing is happening on my production environment (RH linux)  
and on my Mac. So I am sure it is me… I just can’t understand why  
the console and the mongrel are different.

Thanks

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [January 3, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/environment-variables-problem/124873/2 "2008-01-03T17:50:01Z")

</div>

On 1/3/08, phil [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am trying to do something that I thought would be trivial - pulling  
> in a value from an environment variable.  
> in my .bash\_profile I have:  
> XML\_API=[http://192.168.1.5:8080/abp3/webApiXmlRpcServlet](http://192.168.1.5:8080/abp3/webApiXmlRpcServlet)

I assume you probably are but are you actually exporting it?

export XML\_API

> Which is correct.
> 
> But from inside my rails app I get:  
> XML\_RPC\_LOCATION:  
> [http://xxxx/abp3/webApiXmlRpcServlet](http://xxxx/abp3/webApiXmlRpcServlet)
> 
> What is going on?
> 
> The same thing is happening on my production environment (RH linux)  
> and on my Mac. So I am sure it is me… I just can’t understand why  
> the console and the mongrel are different.

It seems like the user you are running your app as doesn’t have access  
to the same environment variables. You can put environment variables  
on the command line to check if that’s the actual problem.

XML\_API=[http://192.168.1.5:8080/abp3/webApiXmlRpcServlet](http://192.168.1.5:8080/abp3/webApiXmlRpcServlet) mongrel\_rails  
start

Or such.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [January 7, 2008, 11:21am UTC](https://www.ruby-forum.com/t/environment-variables-problem/124873/3 "2008-01-07T11:21:26Z")

</div>

Yes, putting it on the command line works…  
How can starting mongrel as my user have a different environment than  
starting the console?
