Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RunCommand incorrectly sets sys.argv for Poetry scripts #965

Closed
3 tasks done
chdsbd opened this issue Mar 16, 2019 · 8 comments · Fixed by #6737
Closed
3 tasks done

RunCommand incorrectly sets sys.argv for Poetry scripts #965

chdsbd opened this issue Mar 16, 2019 · 8 comments · Fixed by #6737
Assignees
Labels
kind/bug Something isn't working as expected

Comments

@chdsbd
Copy link
Contributor

chdsbd commented Mar 16, 2019

  • 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.

@dimaqq
Copy link
Contributor

dimaqq commented Mar 27, 2019

I think I've hit this issue with tornado dev mode hot reload (i.e. tornado restarts when app source code change is detected).

That is, poetry run this-app starts but later fails to reload.
While poetry shell and then this-app starts and later reloads OK.

When reload is broken, tornado tries to restart the app as /path-to-system/python this-app

@chdsbd
Copy link
Contributor Author

chdsbd commented Mar 27, 2019

Yes. I hit this with the Django hot reload server.

@chdsbd chdsbd changed the title Difference in sys.argv between poetry run and poetry shell RunCommand incorrectly sets sys.argv Mar 31, 2019
@chdsbd chdsbd changed the title RunCommand incorrectly sets sys.argv RunCommand incorrectly sets sys.argv for Poetry scripts Mar 31, 2019
@chdsbd
Copy link
Contributor Author

chdsbd commented Mar 31, 2019

@sdispater I've looked into this more and updated the issue with more information. I believe there is bug with RunCommand and poetry scripts.

chdsbd added a commit to chdsbd/poetry that referenced this issue Mar 31, 2019
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
@chdsbd
Copy link
Contributor Author

chdsbd commented Mar 31, 2019

I've opened PR #1001 to fix this.

@brycedrennan brycedrennan added the kind/bug Something isn't working as expected label Sep 2, 2019
@stale
Copy link

stale bot commented Nov 13, 2019

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Nov 13, 2019
@chdsbd
Copy link
Contributor Author

chdsbd commented Nov 13, 2019

This is still an issue. I have a PR open (#1001) that will fix this.

@chdsbd chdsbd mentioned this issue Nov 13, 2019
2 tasks
@sdispater sdispater added stale and removed wontfix labels Nov 14, 2019
@stale stale bot removed the stale label Nov 14, 2019
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 7, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 7, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 8, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 12, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 13, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 13, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 26, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 27, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Oct 31, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Nov 2, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Nov 3, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Nov 4, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
wagnerluis1982 pushed a commit to wagnerluis1982/poetry that referenced this issue Nov 13, 2022
Fixes python-poetryGH-965

Calling `sys.argv` should run the same program as the currently
running program. To make calling Poetry scripts through RunCommand
match this behavior, we must set `sys.argv[0]` to be the full path of
the executable.

This change makes the behavior of calling a script through `poetry run`
the same as calling a script directly from the .venv/bin.
@wagnerluis1982
Copy link
Contributor

wagnerluis1982 commented Jan 13, 2023

A kindly notice to the maintainers, the fix is available, and already applied review commments, at PR #6737

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
5 participants