poetry: `poetry run` regression for handling command flags
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- OS version and name: Darwin 10.14.6
- Poetry version: 1.0.0.b3
- Link of a Gist with the contents of your pyproject.toml file:
Issue
In poetry==1.0.0.b3
, it seems that poetry run
interprets any CLI options as its own rather than passing them through.
For example:
poetry run python manage.py makemigrations --check
> [NoSuchOptionException]
> The "--check" option does not exist.
In poetry==1.0.0.b1
, this was not an issue.
This can be re-created by basic commands like so:
poetry run ls -l
[NoSuchOptionException]
The "-l" option does not exist.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 23
- Comments: 19 (5 by maintainers)
Commits related to this issue
- Add workaround for poetry argument passing bug See this issue: https://github.com/sdispater/poetry/issues/1500 Should be fixed in poetry soon. — committed to BluEye-Robotics/blueye.sdk by sindrehan 5 years ago
- [fix] 'poetry run' cli parsing changed in 1.0.0b3: - '--' is necessary to pass options - Update documentation and CI - See https://github.com/sdispater/poetry/issues/1500 — committed to duniter/silkaj by M5oul 5 years ago
- fix: New version of poetry seems to handle differently arguments of run. Problem looks similar to https://github.com/python-poetry/poetry/issues/1500 — committed to Riminder/hrflow-connectors by deleted user a year ago
Commit 85dc9a1 should fix most of the issues with the
run
command.I will try to make a new beta release this week.
If you upgrade to
1.0.0b3
, you need to use--
to stop options parsing now it looks like.See this change in the
clikit
dependency which poetry uses: https://github.com/sdispater/clikit/pull/2Edit: you shouldn’t need this anymore with the latest 1.0.0b4 release it looks like. That release is more in line with https://github.com/sdispater/poetry/issues/1500#issuecomment-547608347
@sdispater Has this been resolved? I’m still getting an issue when I run
poetry -v run pytest --record-mode=none
The same thing is wrong in when run intox
😦 I’m onPoetry version 1.0.10
Could this be reopened? It seems to have regressed again - I’m using
Poetry version 1.1.11
When any poetry options are included for
poetry run
, the parser consumes all options, making it impossible to pass options to the target command.poetry run
with no options works as expected:But, giving an option, (e.g. to switch off the warning about virtualenv creation), and all options are consumed, causing an error:
This gets even funkier when poetry does support the option that was intended for the target command; poetry acts on that option, instead of passing it through:
The suggested workaround of using a bare
--
does not work either:This is really surprising and unexpected behavior. compare:
in the former case,
abc
is passed to python, in the latter it is passed to poetry. It’s really weird that the discriminant is whether is an option or a vararg. afaict no state of the art cli behaves this way. if you really wanted to discriminate where an argument is passed, thedocker
behavior is more suitableI can confirm that
poetry run pre-commit -- run --all-files
works. It seems like it doesn’t particularly matter where the--
gets put in the command aspoetry run -- pre-commit run --all-files
andpoetry run pre-commit run -- --all-files
seem to have the same effect.I could show
python --help
withpoetry run
by following:In Poetry version 1.0.0b3
I’m experiencing this on Ubuntu 18 with 1.0.0b3 as well. An example when trying to invoke
pre-commit
:For Pip:
For those running into issues installing
poetry==1.0.0.b1
with pipx, this is the workaround I did: