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

Poetry run no longer executes local bash scripts #7959

Closed
4 tasks done
oefe opened this issue May 19, 2023 · 5 comments · Fixed by #7963
Closed
4 tasks done

Poetry run no longer executes local bash scripts #7959

oefe opened this issue May 19, 2023 · 5 comments · Fixed by #7963
Labels
area/cli Related to the command line kind/bug Something isn't working as expected

Comments

@oefe
Copy link

oefe commented May 19, 2023

  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

In Poetry 1.4.2, you could execute local shell scripts using poetry run, e.g. poetry run ./pyright.sh.

This no longer works with Poetry 1.5

>ls -l *.sh
-rwxr-xr-x  1 user  staff  1871 May 19 17:49 pyright.sh*

>head -n 1 pyright.sh
#!/bin/bash

>poetry ./pyright.sh
The command "./pyright.sh" does not exist.

>poetry pyright.sh
The command "./pyright.sh" does not exist.

The changelog mentions #7606, but this should only affect python scripts listed in [tool.poetry.scripts], which is not the case here.

So I would expect that this still works.

Workaround

Explicitly calling bash with the script as argument, i.e. poetry run bash ./pyright.sh still works

@oefe oefe added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 19, 2023
@bellini666
Copy link

Having the same issue for django projects here. They usually have a manage.py executable and in my case, I have a lot of scripts that does poetry run ./manage.py ... which are now failing

@rowanseymour
Copy link

@bellini666 same here, have updated them to poetry run python manage.py ... which works

@danielhoherd
Copy link

danielhoherd commented May 20, 2023

I'm having the same issue for any python script.

$ echo 'print("Hello world")' > test.py
$ chmod +x test.py
$ poetry run ./test.py
Command not found: ./test.py

however, like the original report, specifying the interpreter does work:

$ echo 'print("Hello world")' > test.py
$ poetry run python ./test.py
Hello world
$ echo 'echo "Hello from bash"' > test.sh
$ poetry run bash test.sh
Hello from bash

Including a shebang in the script does not help execute either script directly without specifying the interpreter, nor does using absolute path.

These commands all work as expected in the normal shell and within poetry shell

$ cat test.py
#!/usr/bin/env python3
print("Hello from python")
$ ./test.py
Hello from python
$ poetry run ./test.py
Command not found: ./test.py
$ poetry shell
Spawning shell within /Users/danielh/Library/Caches/pypoetry/virtualenvs/2023-05-20-maEiwDAu-py3.11
$ . /Users/danielh/Library/Caches/pypoetry/virtualenvs/2023-05-20-maEiwDAu-py3.11/bin/activate
(2023-05-20-py3.11) $ ./test.py
Hello from python
$ cat test.sh
#!/usr/bin/env bash
echo "Hello from bash"
$ ./test.sh
Hello from bash
$ poetry run ./test.sh
Command not found: ./test.sh
$ poetry shell
Spawning shell within /Users/danielh/Library/Caches/pypoetry/virtualenvs/2023-05-20-maEiwDAu-py3.11
$ . /Users/danielh/Library/Caches/pypoetry/virtualenvs/2023-05-20-maEiwDAu-py3.11/bin/activate
(2023-05-20-py3.11) $ ./test.sh
Hello from bash

All of this works fine within poetry 1.4.2. I only see the failure in poetry 1.5.0.

@radoering radoering added area/cli Related to the command line and removed status/triage This issue needs to be triaged labels May 20, 2023
@danielhoherd
Copy link

Verified that this was fixed in poetry 1.5.1

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
area/cli Related to the command line kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants