Poetry: `poetry run` regression for handling command flags

Created on 25 Oct 2019  路  16Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] 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.
Bug

Most helpful comment

Commit 85dc9a1 should fix most of the issues with the run command.

I will try to make a new beta release this week.

All 16 comments

I made a couple follow-up comments on this thread that were inaccurate, so I deleted them in order to avoid confusion.

The workaround I'm going to use for now is reverting back to poetry==1.0.0b1 since it seems to be working fine still.

For those running into issues installing poetry==1.0.0.b1 with pipx, this is the workaround I did:

pipx install poetry==1.0.0.b1
pipx runpip poetry==1.0.0b1 install cleo==0.7.5 clikit==0.3.2

For Pip:

pip3 install --user poetry==1.0.0b2 clikit==0.3.2

Same here. (Might be a macOS only thing)

I'm experiencing this on Ubuntu 18 with 1.0.0b3 as well. An example when trying to invoke pre-commit:

15:15 $ poetry run pre-commit run --all-files

[NoSuchOptionException]
The "--all-files" option does not exist.

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/2

Edit: 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

I could show python --help with poetry run by following:

poetry run python -- --help

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:

15:15 $ poetry run pre-commit run --all-files

[NoSuchOptionException]
The "--all-files" option does not exist.

I 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 as poetry run -- pre-commit run --all-files and poetry run pre-commit run -- --all-files seem to have the same effect.

This is really surprising and unexpected behavior. compare:

poetry run python abc
poetry run python --abc

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, the docker behavior is more suitable

docker run --foo image bash # foo passed to docker
docker run image bash --foo # foo passed to subcommand

usage of -- is legitimate when there is an ambiguity, which is not the case for poetry run

Commit 85dc9a1 should fix most of the issues with the run command.

I will try to make a new beta release this week.

Seems like with version 1.0.0b4 this is working again - at least in my case above

I confirm the fix. 1.0.0b4 is ok. Merci @sdispater !

Thanks @sdispater ! Should I close this?

I'm still having this issue with poetry 1.0.5. In my Ansible script I have the shell command
"poetry run manage sync_worker_commands --settings {{ django_settings_module }}"
which fails unless I add an extra --.

@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 in tox :(
I'm on Poetry version 1.0.10

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sobolevn picture sobolevn  路  3Comments

ulope picture ulope  路  3Comments

AWegnerGitHub picture AWegnerGitHub  路  3Comments

ambv picture ambv  路  3Comments

alexlatchford picture alexlatchford  路  3Comments