Skip to content

fix: preserve relative paths in lockfile#6029

Merged
baszalmstra merged 1 commit intoprefix-dev:mainfrom
baszalmstra:fix-issue-4680
May 6, 2026
Merged

fix: preserve relative paths in lockfile#6029
baszalmstra merged 1 commit intoprefix-dev:mainfrom
baszalmstra:fix-issue-4680

Conversation

@baszalmstra
Copy link
Copy Markdown
Contributor

Description

pep508_rs::VerbatimUrl's Display and Serialize impls both write the parsed (normalized) URL and ignore the given string. So any pep508_rs::Requirement that goes through a string round-trip loses its verbatim spelling. The plural convert_uv_requirements_to_pep508 did exactly that:

let requirement = r.to_string();
pep508_rs::Requirement::from_str(&requirement)

For a tool.uv.sources path entry like my-subdir = { path = "my_subdir" }, this produced a Requirement whose VerbatimUrl::given() was the absolute file:// URL of the resolved path. rattler_lock's serializer (requirement_to_string) prefers given(), so the absolute path ended up baked into pixi.lock, breaking sharing across machines.

The sibling to_requirements (singular, for uv_distribution_types::Requirement) already handled this by carrying verbatim.given() over onto a fresh pep508_rs::VerbatimUrl::with_given(...). This PR applies the same treatment to the plural function.

Before:

requires_dist:
  - my-subdir @ file:///tmp/repro/my_subdir

After:

requires_dist:
  - my-subdir @ my_subdir

Fixes #4680

How Has This Been Tested?

  • New unit test relative_path_requirement_round_trip_keeps_given in pixi_uv_conversions::conversions builds a uv Requirement<VerbatimParsedUrl> for my-subdir @ ./my_subdir, runs it through convert_uv_requirements_to_pep508, and asserts the resulting VerbatimUrl::given() is Some("./my_subdir"). The test fails on main and passes after the fix.
  • Full pixi_uv_conversions lib (14 tests) and pixi_core lib (225 tests) suites pass.
  • End-to-end against gabrieldemarmiesse/pixi-bug-repro: deleted the committed pixi.lock, ran the patched binary, and confirmed the regenerated lockfile contains my-subdir @ my_subdir rather than the absolute file:///... URL.

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code (Opus 4.7)

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added sufficient tests to cover my changes.

@baszalmstra baszalmstra requested a review from tdejager May 6, 2026 18:00
…x-dev#4680)

pep508_rs::VerbatimUrl ignores its given string for both Display and
Serialize, so any tool.uv.sources path entry was getting rewritten to an
absolute file:// URL by the time it reached pixi.lock. Patch
convert_uv_requirements_to_pep508 to copy verbatim.given() from the uv
requirement onto the resulting pep508_rs::VerbatimUrl, so rattler_lock's
serializer (which checks given() first) emits the original spelling.

Adds a unit test demonstrating the bug and verifying the fix.
@baszalmstra baszalmstra changed the title fix(uv_conversions): preserve relative paths in lockfile fix: preserve relative paths in lockfile May 6, 2026
Copy link
Copy Markdown
Contributor

@hunger hunger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that will work.

@baszalmstra baszalmstra merged commit ffb8af6 into prefix-dev:main May 6, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using a relative path in tool.uv.sources add the absolute path in pixi.lock

2 participants