python-poetry / python-poetry/poetry

tool.poetry.scripts fails because of a space in path to env

Open
#3,643 3 comments 4 reactions 1 assignee View on GitHub

@Secrus is already working on this.

Since Sep 25, 2024.

area/scripts kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • 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

I followed two articles of Jonathan Bowman:
https://dev.to/bowmanjd/getting-started-with-python-poetry-3ica
https://dev.to/bowmanjd/build-command-line-tools-with-python-poetry-4mnc

In my case the project folder contains a space, which most likely is the reason for the problem.
The entry in pyproject.toml is:

[tool.poetry.scripts]
greet = "greet.location:cli"

The result of calling "greet" is:

(.venv) ➜  pygreet greet                   
zsh: /Volumes/Macintosh SR0/Users/mklengel/Development/pygreet/.venv/bin/greet: bad interpreter: /Volumes/Macintosh: no such file or directory

Having a look in the shebang line of greet shows of course the space in the path:

(.venv) ➜  pygreet head  -1  .venv/bin/greet
#!/Volumes/Macintosh SR0/Users/mklengel/Development/pygreet/.venv/bin/python

The shebang line is created by poetry.

A possible workaround with a symlink to eliminate the space fails:

(.venv) ➜  ~ pwd
/Users/mklengel
(.venv) ➜  ~ ls -l Development 
lrwxr-xr-x  1 mklengel  staff  49 Jan 15 22:03 Development -> /Volumes/Macintosh SR0/Users/mklengel/Development
(.venv) ➜  ~ cd Development/pygreet 
(.venv) ➜  pygreet pwd
/Users/mklengel/Development/pygreet
(.venv) ➜  pygreet poetry shell
Virtual environment already activated: /Volumes/Macintosh SR0/Users/mklengel/Development/pygreet/.venv

poetry "sees" the path but ignores the symbolic link.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.