poetry run --directory command line help error
-
Poetry version: Poetry (version 1.5.1)
-
Python version: 3.10.8
-
OS version and name: macOS
-
[X] I am on the latest stable Poetry version, installed using a recommended method.
-
[X] I have searched the issues of this repo and believe that this is not a duplicate.
-
[x] I have consulted the FAQ and blog for any relevant entries or release notes.
Issue
When doing poetry run --help you get:
-C, --directory=DIRECTORY The working directory for the Poetry command (defaults to the current working directory).
However spelling out the --directory argument with = does not seem to work:
poetry run --directory=/Users/moo/code/executor/trade-executor trade-executor
Command not found: --directory=/Users/moo/code/executor/trade-executor
But it does if you use space instead of =
poetry run --directory /Users/moo/code/executor/trade-executor trade-executor
Usage: trade-executor [OPTIONS] COMMAND [ARGS]...
Try 'trade-executor --help' for help.
Error: Missing command.
wants reporting to cleo
Yeah, this is a known bug in the current CLI parser and the way Poetry implements the run command. Try putting --directory=... before run.
@Secrus would there be any low-hanging fruits to fix this e.g. to change the command line help text?
Yeah, this is a known bug in the current CLI parser and the way Poetry implements the
runcommand. Try putting--directory=...beforerun.
Sadly, doesn't work with Poetry 1.5.1 in my case. Other commands (version, for example) work as described in documentation. So, currently there is no way to set a working directory as a part of poetry command. Hope it'll help to change status of this issue.
C:\Test>poetry --directory=C:\Test\test_project run python builds\health.py
Poetry could not find a pyproject.toml file in C:\Test or its parents
C:\Test>poetry run --directory=C:\Test\test_project python builds\health.py
Poetry could not find a pyproject.toml file in C:\Test or its parents
C:\Test>poetry --directory=test_project version
test-project 0.1.0
C:\Test>poetry --version
Poetry (version 1.5.1)
@Tander I think this might be a different problem. you need to execute the poetry run command from your project's root dir (e.g. c:\Test\pyproject.toml must exist and poetry run needs to be executed from c:\Test. The idea of the directory command is to start from root and then set the given directory as cwd for the run command - at least that's what I guess from the description ;-)
Then directory command doens't make much sense...
This should now be fixed with recent changes to both --directory/--project flags and CLI parsing.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.