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

dotenv file arg should take precedence over default dotenv files #5628

Closed
davidism opened this issue Nov 6, 2024 · 0 comments · Fixed by #5630
Closed

dotenv file arg should take precedence over default dotenv files #5628

davidism opened this issue Nov 6, 2024 · 0 comments · Fixed by #5630
Assignees
Labels
Milestone

Comments

@davidism
Copy link
Member

davidism commented Nov 6, 2024

As pointed out in #5532, -e file is loaded after the default .env and .flaskenv files, which means it won't override env vars that are set by the defaults. It will be a little tricky to track during CLI startup, but I think it should be possible to fix this so that precedence is: os.environ > -e path > .env > .flaskenv.

@davidism davidism added this to the 3.1.0 milestone Nov 6, 2024
jalaj711 added a commit to jalaj711/flask that referenced this issue Nov 7, 2024
)

Signed-off-by: Jalaj <96870071+jalaj711@users.noreply.github.com>
jalaj711 added a commit to jalaj711/flask that referenced this issue Nov 7, 2024
…ult files

In the previous commit, pallets#5628 was fixed by creating the context
before loading the default environment variables. However, as
pointed out by @davidism, this can cause issues with the load
pipeline. Thus, this commit reverses that approach and uses the
`override` argument provided by `python-dotenv` to give priority
to custom file over default file.

Signed-off-by: Jalaj <96870071+jalaj711@users.noreply.github.com>
@davidism davidism self-assigned this Nov 7, 2024
@davidism davidism added the cli label Nov 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant