python-poetry / python-poetry/poetry
poetry run raises FileNotFoundError without any more information (workaround found)
Nobody has claimed this yet.
- 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 (
-vvvoption).
- OS version and name: docker alpine:3.13
- Poetry version: 1.1.4
- Link of a Gist with the contents of your pyproject.toml file: vanilla project from
poetry initwith a main.py and the followingscriptssection:
[tool.poetry.scripts]
main = "main:main"
Issue
Using the following Dockerfile as base image on our build pipeline.
FROM alpine:3.13
RUN apk add --update --no-cache python3 python3-dev py3-pip py3-pandas py3-numpy-dev hdf5-dev
RUN pip install poetry
RUN poetry config virtualenvs.create false
poetry run main crashes with the following error:
/workdir # poetry init
/workdir # poetry run -vvv main
FileNotFoundError
[Errno 2] No such file or directory
at /usr/lib/python3.8/os.py:601 in _execvpe
597│ path_list = map(fsencode, path_list)
598│ for dir in path_list:
599│ fullname = path.join(dir, file)
600│ try:
→ 601│ exec_func(fullname, *argrest)
602│ except (FileNotFoundError, NotADirectoryError) as e:
603│ last_exc = e
604│ except OSError as e:
605│ last_exc = e
Note that enabling or disabling
virtualenvs.createhas the same effect.
Long story short, I've been able to work around the issue and hope this might help others. Here is what did the trick:
/workdir # ln -s /usr/bin/python3 /usr/bin/python
It seems that poetry run is expecting python to be found in the PATH (https://github.com/python-poetry/poetry/blob/master/poetry/console/commands/run.py#L40) on contrary to poetry which is directly using python3:
/workdir # head -1 /usr/bin/poetry
#!/usr/bin/python3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with poetry/console/commands/run.py and reproduce the command in the Alpine 3.13 Docker environment described in the issue. Check how poetry run resolves the configured script when only python3 is available, and use the existing traceback and workaround to define the expected behavior or error message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100