Skip to content

fix: uv cannot lock a project that declares no name or version - #3849

Merged
frostming merged 4 commits into
pdm-project:mainfrom
VXNCXNX:fix/uv-project-without-name
Aug 17, 2026
Merged

fix: uv cannot lock a project that declares no name or version#3849
frostming merged 4 commits into
pdm-project:mainfrom
VXNCXNX:fix/uv-project-without-name

Conversation

@VXNCXNX

@VXNCXNX VXNCXNX commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What's broken

With use_uv enabled, a project that declares no project.name cannot be locked or installed. uv requires name and version, PDM allows an application to omit both, and the pyproject.toml PDM generates for uv omits them too.

Fixes #3421

Repro

A pyproject.toml with a description and dependencies but no name or version:

$ pdm lock
before:
  TOML parse error at line 1, column 1
  `pyproject.toml` is using the `[project]` table, but the required
  `project.name` field is not set
  error: Failed to parse: `pyproject.toml`

after:
  Resolved 2 packages in 2ms
  Lock successful.
$ pdm install
  Installed 1 package in 3ms
   + packaging==26.3

The fix

Write a placeholder name and version into the generated file, then filter that root entry out again when the uv lockfile is read back, so it never reaches pdm.lock. The version is only filled when it is not declared dynamic, otherwise a dynamic version would be overwritten.

Verification

Two tests, one per half of the fix. Removing the name fill fails the first, dropping the dynamic-version guard fails the second.

I ran the real commands rather than only the unit tests: pdm lock and pdm install against a real uv, and grep confirms the placeholder does not appear in the generated pdm.lock. A named project and a project with a dynamic version both still lock unchanged.

Suite: 1340 passed. Two failures, test_run_script_with_inline_metadata and test_export_from_pylock_not_empty, are identical on a clean checkout here. ruff check and ruff format --check clean on the touched files.

uv requires project.name and project.version, while PDM allows an
application to omit both. The generated pyproject.toml omitted them too,
so uv failed to parse it. A placeholder is written instead, and the
resulting root entry is filtered out again when the lockfile is read
back so it never reaches pdm.lock.

Fixes pdm-project#3421
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.47%. Comparing base (29c40ea) to head (ef4c8c3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/pdm/formats/uv.py 96.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3849      +/-   ##
==========================================
+ Coverage   88.41%   88.47%   +0.06%     
==========================================
  Files         121      121              
  Lines       13258    13270      +12     
  Branches     2252     2253       +1     
==========================================
+ Hits        11722    11741      +19     
+ Misses        966      963       -3     
+ Partials      570      566       -4     
Flag Coverage Δ
unittests 88.36% <96.42%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tests/resolver/test_uv_resolver.py is marked network at module level, so
the test was deselected in CI and the resolver change stayed uncovered.
It reads a uv.lock from disk and needs no network.
@frostming
frostming merged commit 85ae8d2 into pdm-project:main Aug 17, 2026
25 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.

Unable to pdm sync / install an application with uv without a project name / version

2 participants