Poetry: `poetry run` should look in current directory for executable

Created on 27 Jun 2019  路  2Comments  路  Source: python-poetry/poetry

  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] I have searched the documentation and believe that my question is not covered.

Feature Request

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.

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, 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

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings