Skip to content

Conversation

VarunAgw
Copy link

@VarunAgw VarunAgw commented Apr 5, 2025

Fixes #1042

@VarunAgw VarunAgw changed the title issue-1024 Added a feature to optionally override existing environment variables set by the system Added a feature to optionally override existing environment variables set by the system Apr 5, 2025
@nicolas-grekas
Copy link
Member

Can you expand? Why can't you set your real env var to the value you need? Or why can't you remove said real env vars instead?
You can already override real env vars by listing them in the SYMFONY_DOTENV_VARS env var. Isn't this a better way to cover your use case?
Adding options adds complexity. Better not if possible.

@VarunAgw
Copy link
Author

VarunAgw commented Apr 7, 2025

Hi @nicolas-grekas

Here is my code structure

.env

  • Some data

.env.local

  • APP_ENV=prod_conf1

.env.prod_conf1

  • APP_ENV=prod
  • APP_NAME=conf1
  • some more data

.env.prod_conf2

  • APP_ENV=prod
  • APP_NAME=conf2
  • some more data

Without an override flag, I can't override the value of APP_ENV in .env.prod_conf1

@VarunAgw
Copy link
Author

VarunAgw commented Apr 7, 2025

I can't override APP_ENV using SYMFONY_DOTENV_VARS feature.

@VarunAgw
Copy link
Author

Bump @nicolas-grekas

@VarunAgw
Copy link
Author

Hi @nicolas-grekas Bump

@nicolas-grekas
Copy link
Member

I'm 👎
Thanks for the explanations but I think this is too specific.
I think you can achieve what you want using cp: instead of editing .env.local to switch APP_ENV, use cp .env.prod_conf1 .env.prod instead.

@VarunAgw
Copy link
Author

Sure, thanks for letting me know

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 this pull request may close these issues.

Allow override of existing environment variables set by the system optionally via a flag in DumpEnvCommand

2 participants