-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DotEnv] .env.local should override existing defined variables #29647
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
Comments
@ro0NL Thanks, but I'm not running this inside Docker. |
So no "real env vars" are involved? I was unable to reproduce it actually, for me it seems to just work (i both tested .env OR .env.dist, with AND without .env.local. |
@ruudk Can you create an example application that allows to reproduce? |
I'm sorry but I just checked out a new project, and it just works like you expect it to work. Then I retried on my own project and it worked. I feel really silly now :( Thanks for the fast help, not sure what was going wrong. |
Ok, it appears that the issue is related to Symfony Cloud CLI tool not reading the .env files. How to reproduce?
I guess I have to report this at https://github.com/symfonycorp/symfony-cli-issues? |
Found out that the issue is that Symfony CLI passes |
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.2.1
Description
I'm following the new approach to .env files as described here.
My
.env
file contains:And my
.env.local
file contains:STRIPE_KEY=MY_KEY
When I create a service that injects this
%env(STRIPE_KEY)%
it's always empty.When I remove the
STRIPE_KEY=
placeholder from my.env
file it suddenly works.The issue is that it first loads the
.env
file, sets theSTRIPE_KEY
to blank, then loads the.env.local
file and just skips theSTRIPE_KEY=MY_KEY
because it's already defined.Possible Solution
Always let
.env.local
override the environment variables defined in.env
The text was updated successfully, but these errors were encountered: