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

APP_ENV overrides RAILS_ENV #4560

Closed
prem-prakash opened this issue May 7, 2020 · 11 comments
Closed

APP_ENV overrides RAILS_ENV #4560

prem-prakash opened this issue May 7, 2020 · 11 comments

Comments

@prem-prakash
Copy link

Ruby version: 2.7.0
Sidekiq / Pro / Enterprise version(s): 6.0.5

https://github.com/mperham/sidekiq/blob/22e812d3f1ae9a3e5faa79637a61705186d6961e/lib/sidekiq/cli.rb#L244

Although APP_ENV will possibly become a default soon, a user may inadvertently or unintentionally overwrite RAILS_ENV by setting APP_ENV.

@mperham
Copy link
Collaborator

mperham commented May 7, 2020

Correct. By design.

@mperham mperham closed this as completed May 7, 2020
@prem-prakash
Copy link
Author

If Rails does not use APP_ENV, it is not correct, it is unexpected behavior and it is not documented. It is at least an incompatibility with the most current Rails.

@mperham
Copy link
Collaborator

mperham commented May 7, 2020 via email

@mperham
Copy link
Collaborator

mperham commented May 8, 2020

@prem-prakash
Copy link
Author

Thank you 🙏

@TheKidCoder
Copy link

TheKidCoder commented Sep 9, 2020

@mperham This is causing issues in our app and will require a change to a number of areas - is there a reason we can't just simplify this to a SIDEKIQ_ENV?

@mperham
Copy link
Collaborator

mperham commented Sep 9, 2020

@TheKidCoder Have you tried sidekiq -e? 😂

@stevehanson
Copy link

This is also causing an issue for me as I use APP_ENV for other purposes. A simple solution would be to also support SIDEKIQ_ENV and have it take precedence over any other ENV variables. Happy to make a PR if we're open to this.

@mperham
Copy link
Collaborator

mperham commented Sep 7, 2021

@stevehanson Is there some reason you can't use -e?

@stevehanson
Copy link

We have a script to launch sidekiq that is used in different environments and doesn't have access to the dotenv config where RAILS_ENV is set. I just updated our app to use something other than APP_ENV since that seemed to be the simplest recourse in my case.

More generally, it seems like if Sidekiq uses a generic name like APP_ENV, it should provide a mechanism to get around it without having to modify build scripts. Another gem or app code could just as easily also use APP_ENV but in a different way.

@mperham
Copy link
Collaborator

mperham commented Sep 7, 2021

I've opened an issue with puma about the variable. puma/puma#2692

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

4 participants