python-poetry / python-poetry/poetry
Subsequent `poetry install` fails with transitive path dependencies via git subdir dependency
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
Description
Poetry fails to correctly install when it has a transitive path dependency via a git subdirectory dependency.
Same as this closed issue https://github.com/python-poetry/poetry/issues/8765; the example is taken from there and modified to run poetry install twice.
It seems poetry is resolving the path of the transitive namespace-lib relative to the root directory of the poetry-managed virtualenv, whereas it should be resolving the path relative to the subdirectory of the git dependency.
It appears to succeed on first install, but breaks on any subsequent attempts with the message Directory /usr/lib for namespace-lib does not seem to be a Python package (or more often Path <path> for <package> does not exist in cases when the incorrectly resolved path doesn't correspond to an existing dir).
Workarounds
Remove the current env and start fresh for every install/sync
Poetry Installation Method
pip
Operating System
macos 14.1.2 + debian 12 (6.12.9-200.fc41.aarch64)
Poetry Version
2.1.1
Poetry Configuration
cache-dir = "/root/.cache/pypoetry"
data-dir = "/root/.local/share/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}/python" # /root/.local/share/pypoetry/python
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /root/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false
Python Sysconfig
No response
Example pyproject.toml
[project]
name = "example"
requires-python = "~3.10"
[tool.poetry]
requires-poetry = "^2.0"
package-mode = false
[tool.poetry.dependencies]
namespace-cli = {git = "https://github.com/adriangb/python-monorepo.git", subdirectory = "poetry/workspaces/cli", rev = "9bb66f4"}
Poetry Runtime Logs
Reproduce with:
podman run --rm -i --entrypoint bash python:3.10 <<EOF
set -xe
python -m pip install --disable-pip-version-check --root-user-action ignore -q poetry
cat > pyproject.toml <<TOML
[project]
name = "example"
requires-python = "~3.10"
[tool.poetry]
requires-poetry = "^2.0"
package-mode = false
[tool.poetry.dependencies]
namespace-cli = {git = "https://github.com/adriangb/python-monorepo.git", subdirectory = "poetry/workspaces/cli", rev = "9bb66f4"}
TOML
poetry install
poetry install
EOF
Output:
+ python -m pip install --disable-pip-version-check --root-user-action ignore -q poetry
+ cat
+ poetry install
Creating virtualenv example-il7asoJj-py3.10 in /root/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...
Package operations: 12 installs, 0 updates, 0 removals
- Installing dnspython (2.7.0)
- Installing idna (3.10)
- Installing typing-extensions (4.12.2)
- Installing annotated-types (0.7.0)
- Installing email-validator (2.2.0)
- Installing pydantic-core (2.27.2)
- Installing commonmark (0.9.1)
- Installing pydantic (2.10.6)
- Installing pygments (2.19.1)
- Installing namespace-lib (0.0.0 /root/.cache/pypoetry/virtualenvs/example-il7asoJj-py3.10/src/python-monorepo/poetry/workspaces/lib)
- Installing rich (12.6.0)
- Installing namespace-cli (0.0.0 9bb66f4)
Writing lock file
+ poetry install
Installing dependencies from lock file
Directory /usr/lib for namespace-lib does not seem to be a Python package
Directory /usr/lib for namespace-lib does not seem to be a Python package
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 the pyproject.toml example and run the provided container reproduction, especially the two consecutive poetry install commands. Trace handling of git dependencies with a subdirectory and their transitive path dependency; done means the second install completes without misresolving namespace-lib, with regression coverage for this reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100