Skip to content

RunCommand incorrectly sets sys.argv for Poetry scripts #965

@chdsbd

Description

@chdsbd
  • 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).

Issue

sys.argv varies when running package through poetry run vs poetry shell

  • poetry run cli, sys.argv == ['cli']
  • poetry shell && cli, sys.argv == ['/full/path/to/package/.venv/bin/cli']

EDIT: I've looked into this a little bit more and it seems like this RunCommand code is the root of the issue. We are assigning incorrect values to sys.argv for the executable. I believe that sys.argv should be args that, if called, will run the same program as the running program.

poetry shell is going to always work correctly because it doesn't touch Poetry. The virtualenv is added to the path so we're calling directly to the executable in the virtualenv bin.

For the fix, I think we want to lookup the full path to the Poetry script in virtualenv bin and use that executable path as the first arg in sys.argv. I think that should fix this issue and make the behavior of calling scripts through poetry run equal to poetry shell.

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions