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

.env.local should have higher priority than .env.<environment> #73

Closed
helloitsjoe opened this issue Jun 2, 2022 · 2 comments · Fixed by #74
Closed

.env.local should have higher priority than .env.<environment> #73

helloitsjoe opened this issue Jun 2, 2022 · 2 comments · Fixed by #74

Comments

@helloitsjoe
Copy link
Contributor

helloitsjoe commented Jun 2, 2022

Description

#37 added support for --casacade, which allows .env, .env.local, .env.<environment>, .env.<environment>.local to override each other in priority. The PR references Create React App, NextJS, and Symfony for the priority order.

However, the priority order in dotenv-cli doesn't match Create React App or NextJS, which I believe is a bug.

NextJS and Create React App both use the following priority, with .env.local values overriding those in .env.development:

  1. .env.development.local (Highest)
  2. .env.local
  3. .env.development
  4. .env (Lowest)

(NextJS .env docs here, CRA docs here - note the second section, under "Files on the left have more priority than files on the right")

The CRA source also includes a comment that references bkeepers/dotenv which specifies the same priority in their readme. The NextJS source doesn't include the comment but the implementation is very similar.

Symfony, however, swaps .env.local and .env.development, giving .env.development priority (and looks like this is what @plashenkov modeled the behavior in #37). I think this is actually a bug in Symfony, since the PR that added this behavior references CRA and bkeepers/dotenv, so it looks like they made a mistake in the implementation.

It would be great if dotenv-cli could match Create React App and NextJS, I'm happy to submit a PR for this if you're open to it!

@helloitsjoe
Copy link
Contributor Author

@entropitor Any thoughts/feedback on this?

@helloitsjoe
Copy link
Contributor Author

Thank you!

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

Successfully merging a pull request may close this issue.

1 participant