Skip to content

--project and lock produces incorrect relative path in lock file #9692

@JamesMTSloan

Description

@JamesMTSloan

Minimal reproduction

Running in /home/user/projects/uv_test with uv 0.5.6.

mkdir other
mkdir project
cd project
uv init
cd ../other
uv --project ../project/ lock
uv --project ../project/ run python3 hello.py

Gives the following output:

Initialized project `project`
Using CPython 3.10.12 interpreter at: /usr/bin/python3.10
Resolved 1 package in 2ms

Using CPython 3.10.12 interpreter at: /usr/bin/python3.10
Creating virtual environment at: ../project/.venv
error: Failed to generate package metadata for `project==0.1.0 @ virtual+../../../project`
  Caused by: Distribution not found at: file:///home/user/project

Contents of project/uv.lock:

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

[[package]]
name = "project"
version = "0.1.0"
source = { virtual = "../../../project" }

The relative path that ends up in the lock file is incorrect. Using --directory instead of --project produces the expected "." path.
Nor is the path produced, "../../../project", the one given as --project - it ends up pointing to a somewhat arbitrary directory and so with some bad luck could produce some very unexpected results if it happens to hit a different valid project. In my case the concrete project is at /home/user/projects/uv_test/project with uv looking in /home/user/project.

To be clear, in my usecase switching to --directory worked. Maybe this is expected behaviour but I am reporting it as it surprised me.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions