How do I setup a local environmental variable?


so for example in heroku you can do

heroku config:set KEY=mysecretkey

but how can i do that locally with c9?

so for example i have in my code in a rails app in development.rb

host = ‘

what if i don’t want to show that info? could i set up a ENV variable locally?


you can use the env popup in the runner


where is the runner? i cant find it.


okay i created a runner file, nowhere do i see that ENV button but anways i changed it to

“env” : { ‘LOCAL’:“324901ef94c6ce6457”},

now how do i call it in the code? nothing is working.


press run button, or use new run configuration menu from + button in tabbar.


ok i tried that.

first I input ENV[‘SECRET’] and then “424242424252562”

and then i tried them in the other direction… either way, when i place

ENV[‘SECRET’] in my code, it has no idea what i am talking about.


just to be clear, i want to use this in the middle of my ruby on rails project the same way i would use heroku env variables.



how do you launch the rails process? the env only affects processes running in that tab.
You can also modify ~/.bashrc, to make variables available everywhere, just add export SECRET=42 at the top, and it should be defined in all terminals you open


hi what i mean is this:

class Photo

def post_photos
client =
client.api_key = ENV[‘API_KEY’]

I can set this in Heroku through the command prompt… heroku config:set API_KEY=“2323232323242424”

But now I also want to keep these code working locally… therefore I would like to do something similar with c9…
and when I push the app to bit bucket… when people look at it… they should not be able to figure out what the API_KEY is… thanks a bunch…


how do you run your app? with cloud9 run button, or from commandline?

If the second, the easiest way is to edit ~/.bashrc


ok i ran c9 ~/.bashrc from the command line.

then i tried many combinations but it is still not working. can you please show me explicitly what needs to be written in the bashrc file and what is placed in the rails model ?

class Photo

client.api_key = ENV[‘API_KEY’]

bashrc -> ???



i guess i can just do this…


I came here looking for answers, and I found them elsewhere, so I figured I’d share the knowledge here.

  1. From your directory in the command line run c9 ~/.bashrc

  2. At the end of the .bashrc file that opens, add export API_KEY="your_api_key_here" to the end.
    Save the file.

  3. From the command line, run source ~/.bashrc to load the changes.
    Then restart your console and/or server

To test if it worked, from your reloaded console, run ENV["API_KEY"] and it should output “your_api_key_here” or whatever value you put.

And repeat 1-3 with the ~/.profile file to get it to work in the command line server.


Thanks for the update, but this seems like a pretty clunky implementation (on C9’s part).

in PHP, I can set an ENV variable in the c9 IDE, and then call it thusly:


To use Python I have to update my bash profile? Kinda defeats the purpose of an environment variable, doesn’t it? I should be able to move my code to any platform, set the variable, and then call it. Having to change the bash profile on each platform sorta blows that portability, doesn’t it?