Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAILS_ENV should not be set when using ps:exec #871

Open
jkutner opened this issue Apr 25, 2019 · 3 comments
Open

RAILS_ENV should not be set when using ps:exec #871

jkutner opened this issue Apr 25, 2019 · 3 comments

Comments

@jkutner
Copy link
Contributor

jkutner commented Apr 25, 2019

The ps:exec command does not load config variables, but does run .profile.d scripts. This results in incorrect values being set for RAILS_ENV and RACK_ENV.

For example, if you inspect an app's .profile.d/ruby.sh, you'll see:

~ $ cat .profile.d/ruby.sh | grep _ENV
export RAILS_ENV=${RAILS_ENV:-production}
export RACK_ENV=${RACK_ENV:-production}

Because your custom set RAILS_ENV config var is not load, the profile.d script sets the default value of production.

Correct behavior

The .profile.d/ruby.sh should wrap the export lines in an if guard like:

if [[ -z "$SSH_CLIENT" ]]; then
  export RAILS_ENV=${RAILS_ENV:-production}
  export RACK_ENV=${RACK_ENV:-production}
fi
@schneems
Copy link
Contributor

Wouldn't all default config vars fall into the same trap here?

@jkutner
Copy link
Contributor Author

jkutner commented May 29, 2019

@schneems yes

@schneems
Copy link
Contributor

Related support ticket: https://heroku.support/708919

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants