python-poetry / python-poetry/poetry

Transitive dependencies of path dependencies are not updated with `poetry update X`

Open
#5,111 1 comment 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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).
  • OS version and name: MacOS 11.2
  • Poetry version: 1.1.12
  • Link of a Gist with the contents of your pyproject.toml file: Gist

Issue

In my monorepo project, we have chains of path dependencies. For example, lib_c depends on lib_b which depends on lib_a - see Gist - which are defined in a single directory like

libs/
    lib_a/
        pyproject.toml
        ...
    lib_b/
        pyproject.toml
        ...
    lib_c/
        pyproject.toml
        ...

We have noticed that transitive dependencies of path dependencies are not updated when running poetry update some_path_dependency.

Taking the example lib_c depends on lib_b which depends on lib_a, if a dependency is added to lib_a (for example toml package), running poetry update lib_a in lib_a directory will update the lib_b poetry.lock adding toml as a dependency of lib_a like below.

[[package]]
name = "lib-a"
version = "0.1.0"
description = ""
category = "main"
optional = false
python-versions = "^2.7"
develop = true

[package.dependencies]
toml = "^0.10.2"

[package.source]
type = "directory"
url = "../lib_a"

[[package]]
name = "toml"
version = "0.10.2"
description = "Python Library for Tom's Obvious, Minimal Language"
category = "main"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"

However when running poetry update lib_b in lib_c, toml is not installed or referenced in lib_cs lockfile. See below.

[[package]]
name = "lib-a"
version = "0.1.0"
description = ""
category = "main"
optional = false
python-versions = "^2.7"
develop = true

[package.source]
type = "directory"
url = "../lib_a"

[[package]]
name = "lib-b"
version = "0.1.0"
description = ""
category = "main"
optional = false
python-versions = "^2.7"
develop = true

[package.dependencies]
lib_a = {path = "../lib_a", develop = true}

[package.source]
type = "directory"
url = "../lib_b"

This results in ImportErrors when trying to use lib_c.

We have found a workaround which is to run poetry update lib_a lib_b on lib_c but this seems like a bug. We would expect that poetry update some_package would capture and update all nested dependencies in the lockfile too.

Running poetry update on lib_c (i.e. without specifying the packages to update) also works however no desirable for us since we want to update our path dependencies only.

We also tried poetry lock --no-update on lib_c but that does not add toml to the lib_c lockfile - that is likely expected.

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.

Research direction

Reproduce the lib_a → lib_b → lib_c setup from the linked pyproject.toml gist, using poetry update on the path dependency. Inspect how the command produces each poetry.lock file and compare the direct and transitive dependency entries. Done means updating lib_b in lib_c also records and installs lib_a's newly added dependency without requiring both packages to be named.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.