Stop change CWD to .env/.flaskenv location#3560
Conversation
|
Thanks for the ping on this, @davidism. I can confirm these changes don't break anything in my customized Flask CLI (since mine does some more sophisticated detection of .env files that is independent of Flask's built-in detection, which I can explain more in #3108 or elsewhere). And these changes seem good to me otherwise. Silently changing the CWD based on the presence/location of (hidden) .env files seems like it can break things in a hard-to-debug way for users. I may be missing something, since I'm not clear on what the benefit was in the first place. I'd expect users needing to compute paths relative to their app's modules should be doing so in a CWD-independent way (e.g. using The only thing missing before I think this can be merged is an update to the changelog. Thanks @greyli for contributing this! |
|
This looks good to me, and no one's raised any concerns, so I'm going to merge this before it stalls any longer. |
By the current implementation, if
.envor.flaskenvwas found in the top-level directory, Flask will change the current work directory to the directory that contains the.envor.flaskenvfile.When the user accidentally put a
.envor.flaskenvin the top-level directory, then executingflask runin the current directory (containsapp.py) will throw out NoAppException.See more in #3561.