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

uv lock collapses relative paths to editable builds in monorepo, breaks uv sync #6371

Closed
leddy231 opened this issue Aug 21, 2024 · 3 comments · Fixed by #6490
Closed

uv lock collapses relative paths to editable builds in monorepo, breaks uv sync #6371

leddy231 opened this issue Aug 21, 2024 · 3 comments · Fixed by #6490
Assignees
Labels
bug Something isn't working

Comments

@leddy231
Copy link

Hi there! Excited to move our monorepo from poetry to uv.

There seems to be an issue with relative paths for editable installs in the lockfiles.
Using the following demo structure:

root
├-libs
│  ├-liba
│  └-libb
└-projects
   └-projecta

liba, libb, and projecta created with uv init

libb depends on liba with an editable install

dependencies = [
    "liba"
]

[tool.uv.sources]
liba = { path = "../../libs/liba", editable = true }

When locking libb with uv lock the path is resolved correctly, but also collapsed in the lockfile

[[package]]
name = "liba"
version = "0.1.0"
source = { editable = "../liba" }

This works fine since the path it correct.

However this does not work for projecta, which depends on libb:

dependencies = [
    "libb"
]

[tool.uv.sources]
libb = { path = "../../libs/libb", editable = true }

uv lock produces this lockfile:

version = 1
requires-python = ">=3.12"

[[package]]
name = "liba"
version = "0.1.0"
source = { editable = "../liba" }

[[package]]
name = "libb"
version = "0.1.0"
source = { editable = "../../libs/libb" }
dependencies = [
    { name = "liba" },
]

[package.metadata]
requires-dist = [{ name = "liba", editable = "../liba" }]

[[package]]
name = "projecta"
version = "0.1.0"
source = { editable = "." }
dependencies = [
    { name = "libb" },
]

[package.metadata]
requires-dist = [{ name = "libb", editable = "../../libs/libb" }]

Where the collapsed relative path is still used for liba, which no longer works.
This makes uv sync fail:

error: Failed to determine installation plan
  Caused by: Distribution not found at: file:///home/martin/uv_monorepo_bug/projects/liba
@charliermarsh charliermarsh added the bug Something isn't working label Aug 21, 2024
@charliermarsh charliermarsh self-assigned this Aug 21, 2024
@charliermarsh
Copy link
Member

Thanks, I'll take a look!

@charliermarsh
Copy link
Member

Agree this is a bug, just reproduced.

@charliermarsh charliermarsh removed their assignment Aug 22, 2024
@charliermarsh
Copy link
Member

@konstin -- Do you mind taking a look at this in the morning?

@konstin konstin self-assigned this Aug 22, 2024
konstin added a commit that referenced this issue Aug 22, 2024
Pass the location of `uv.lock`, the base of our relative lockfile pass, through when locking in project mode. This fixes previous incorrect paths that were using the root of the other workspace as reference for the relative path.

Fix #6371.
konstin added a commit that referenced this issue Aug 22, 2024
Pass the location of `uv.lock`, the base of our relative lockfile pass, through when locking in project mode. This fixes previous incorrect paths that were using the root of the other workspace as reference for the relative path.

Fix #6371.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants