-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
-
Poetry version: 1.3.2
-
Python version: 3.10
-
OS version and name: Arch Linux
-
pyproject.toml: Not relevant (more info on the issue)
-
I am on the latest stable Poetry version, installed using a recommended method.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
I have consulted the FAQ and blog for any relevant entries or release notes.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.
Issue
This issue is a follow-up of flask#2588. You can get the full context there.
When running a script, Poetry is mutating the sys.argv. This breaks and violates the documented behavior of sys.argv and, therefore, must be avoided.
Regarding the practical issue (besides breaking the documented behavior of sys.argv), Flask reloader relies on sys.argv to reload the application automatically. Due to this, we can't launch a Flask application with the reloader enabled due to this issue.
You can replicate this bug by doing the following:
- Create a new Poetry application
- Install Flask on it
- Setup a minimal Flask application
- Add a poetry script that will launch that application, something like:
[tool.poetry.scripts]
dev = 'my_package.main:run'- On your shell, set
FLASK_DEBUG=1 - Execute the Poetry script:
poetry run dev - You're going to get an error, saying that Python wasn't able to open the file called
dev(due to the fact that Poetry script is settingsys.argv = ["dev"] - Now, set
FLASK_DEBUG=0 - Launch the script again
- You'll see that, now, it works as expected
I've already opened that issue on Flask, and you can check Flask's team explanation about why this issue isn't related to them on this comment