In a Django project, running poetry run manage.py when manage.py is in the current directory returns an error saying the file cannot be found.
$ poetry run manage.py
[FileNotFoundError]
[Errno 2] No such file or directory: 'manage.py': 'manage.py'
run <args> (<args>)...
However, the following works
$ poetry run ./manage.py
Type 'manage.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[account]
account_unsetmultipleprimaryemails
[auth]
changepassword
...
It would be helpful if poetry run looked in the current directory for files to run.
This seems like an issue with your execution path and not with Poetry. If you do not have the current directory (.) added to your path, typing manage.py into your terminal without poetry will not execute it.
I think the principle of least surprise would dictate that poetry run looks for a script (from the [tools.poetry.scripts] section of pyproject.toml) matching the first argument and after that fall back to the operating system's lookup for executables (within the context of a virtualenv).
Incidentally, poetry run python manage.py will work just fine
Yeah, I think you're right.
Most helpful comment
This seems like an issue with your execution path and not with Poetry. If you do not have the current directory (
.) added to your path, typingmanage.pyinto your terminal without poetry will not execute it.I think the principle of least surprise would dictate that
poetry runlooks for a script (from the[tools.poetry.scripts]section of pyproject.toml) matching the first argument and after that fall back to the operating system's lookup for executables (within the context of a virtualenv).Incidentally,
poetry run python manage.pywill work just fine