can not override environment settings that already have value with a file
See original GitHub issueI have
env = environ.Env(
DEBUG=(bool, False),
)
ENV_FILE = str(env.path('ENV_FILE', default='/'))
if os.path.isfile(ENV_FILE):
overrides = {'DATABASE_URL': os.environ.pop('DATABASE_URL', '')}
env.read_env(env_file=ENV_FILE, **overrides)
else:
# unset if no file was found
ENV_FILE = None
Problem is that in my ENV_FILE, I want to set DATABASE_URL
that already has a value when reading the ENV_FILE.
But because def read_env(env_file=None, **overrides)
uses setdefault(key, str(val))
this value can not be overwritten.
Is it possible to extend def read_env
with an extra boolean argument to decide whether or not to override existing environment variables?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:13 (2 by maintainers)
Top Results From Across the Web
c# - can't override appsettings.json settings with environment ...
Update 2: I restarted my computer and now I see my Environment variable in the list, but it doesn't override the value in...
Read more >Overriding One Single Value in Your Docker-Compose .env File
env file is reasonably simple: just set an environment variable with the same name in your shell before running your docker-compose command. This...
Read more >Environment variables in Compose | Docker Documentation
You can override the environment file path using a command line argument --env-file . Using the “--env-file” option . By passing the...
Read more >Why isn't my ASP.NET Core environment-specific ...
There are a number of ways you could achieve this, for example: Overwrite default values e.g. only set an environment variable for the...
Read more >Use multiple environments in ASP.NET Core | Microsoft Learn
json override values set in the system environment. The launchSettings.json file: Is only used on the local development machine. Is not deployed ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 for merging PR #191.
The similar
python-dotenv
project does have anoverride=True
option.https://github.com/theskumar/python-dotenv#getting-started
Simple to load env file to override environments from settings: