You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.9 KiB
2.9 KiB
| title | module | component | problem_type | severity | date | tags |
|---|---|---|---|---|---|---|
| uv.lock parse error due to pytest entry missing source | tooling | tooling | build_error | medium | 2026-04-05 | [uv lockfile pytest packaging streamlit] |
Problem
Running uv commands failed with a parse error in uv.lock caused by an ambiguous/malformed pytest entry that lacked a proper source field and conflicted with another package entry.
Symptoms
uv run streamlit run Home.pyfailed with: "Dependencypytesthas missingsourcefield but has more than one matching package".uv lockanduv addalso failed becauseuv.lockcould not be parsed.
What didn't work
- Attempting
uv add "pytest>=9.0.2" --devfailed because the lockfile parser errored before the command could modify anything. - Manual edits to
uv.lockwere used as a temporary stop-gap (alloweduvto run) but are not a durable solution becauseuv.lockis generated.
Solution
-
Regenerate the lockfile from
pyproject.tomlsouv.lockand project metadata are consistent:- Run:
uv lock - Inspect the resulting
uv.lockto ensurepytestappears as a single[[package]]entry with asourcefield and expected hashes.
- Run:
-
Commit the regenerated lock locally (do not push without review):
git add uv.lockgit commit -m "chore: regenerate uv.lock (resolve pytest source ambiguity)"
Why this works
uv.lockis the canonical, generated lockfile. The parser expects each package entry to have an unambiguoussourcesouvcan resolve hashes and reproducible installs. Regenerating produces a consistent lockfile derived frompyproject.tomland resolves duplicated/malformed entries.- Manual edits fix symptoms but can be overwritten or lead to inconsistent state; regenerating ensures upstream metadata and lockfile match the resolver's expectations.
Prevention
- Avoid hand-editing
uv.lock. When a lockfile parse error appears, prefer regenerating withuv lock. - Add a lightweight CI check to ensure
uv lock --check(oruv lockwith no changes) passes before merging changes that touch dependencies or the lockfile. - Make
pytest(and other dev tools) authoritative inpyproject.tomlunderdependency-groups.devso the resolver has a single source of truth.
Verification
-
After regeneration, verify
uvcommands work and tests run:uv run streamlit run Home.py→ Streamlit should start and print Local/Network URL.venv/bin/python -m pytest tests/ -q→ Confirm tests run (example in this run:171 passed, 2 skipped).
Related files
uv.lockpyproject.toml
If you want, I can:
- Run the Streamlit verification now, or
- Propose a small CI job snippet to enforce
uv lock --check, or - Create a short PR description if you want this committed change pushed and opened as a PR.