Problem setting environment variables


#1

Hi!

I’m trying to set some environment variables that will be available to my Rails app, using the ENV-button in the runner. When i check for the presence of these variables in the Rails console, running ENV[“VARIABLE_NAME”], it outputs nil. I have tried to restart the app and the console, with no luck.

Any idea of what I’m doing wrong?


browserSync elixir in laravel skips opened assigned port
#2

runner sets only variables in its own terminal. If you want to change a variable everywhere
run c9 ~/.bashrc and add export VARIABLE_NAME=VARIABLE_VALUE to the end


#3

Thanks for your reply, harutyun! Can you please explain something for me? What do you mean by “it’s own terminal” when this runner/terminal runs the rails server for my app, shouldn’t the variables be available to that same app?

And if I set the variables using c9 ~/.bashrc, and they become available everywhere, does this mean everywhere in the workspace or all my C9 workspaces?

My issue originates in this unanswered question on stackoverflow, where I can’t seem to do the “simple” task of setting environment variables for Gmail credentials in a Rails mailer: http://stackoverflow.com/questions/38637185/rails-cant-get-mailer-to-work-when-i-set-credentials-as-environment-variables


#4

I set a variable using .bashrc as the answer suggested. When I run my rails console, I can access that variable via ENV. However it’s apparently not accessing it when loading the development.rb environment file.

Setting a group of configurations in ENV is a ubiquitous part of running Rails apps. I suggest adding support for this to c9. The ENV menu in the Rails server’s terminal should set the ENV variable in all the terminals. Thanks!


#5

That worked thank you sooo much. I spent hours trying to get my env variables to work on c9.