Closed Lingepumpe closed 2 days ago
If required, I can create a minimal example to reproduce. Just let me know if that would be useful.
Isn't using --locked
sufficient to check if uv.lock is up-to-date?
uv sync --locked
If you simply want the lock file to be automatically updated to the latest version, then you don't need to use either --locked or --frozen
The project is re-locked before syncing unless the --locked or --frozen flag is provided.
By using both --locked
and --frozen
, are you attempting to make UV verify that the lock file is current without allowing it to modify the lock file?
https://docs.astral.sh/uv/reference/cli/#uv-sync
--locked
Assert that the uv.lock will remain unchanged.
Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.
May also be set with the UV_LOCKED environment variable.
--frozen
Sync without updating the uv.lock file.
Instead of checking if the lockfile is up-to-date, uses the versions in the lockfile as the source of truth. If the lockfile is missing, uv will exit with an error. If the pyproject.toml includes changes to dependencies that have not been included in the lockfile yet, they will not be present in the environment.
May also be set with the UV_FROZEN environment variable.
--locked
requires that we can access the project metadata. Are you using dynamic metadata, or something like that? If so, we have to build the project from source.
--locked
requires that we can access the project metadata. Are you using dynamic metadata, or something like that? If so, we have to build the project from source.
Indeed, my pyproject.toml
contained dynamic = ["version"]
- I am not sure why. I don't think it was necessary, as the version itself was a fixed string. Removing this line makes it work with --locked
instead of --frozen
.
I have also made a example that reproduces it, in case it is useful: https://github.com/Lingepumpe/uv_locked_frozen_reproduction
Simply running docker build .
in the repo will result in the error - commenting out the dynamic line in pyproject.toml will avoid the error.
The question remains: Why does --locked
require extra steps when compared with --frozen
? In the scenario of the Dockerfile, the idea is to check the uv.lock file and install the dependencies as early as possible, without needing to copy in the full source tree, for optimal layer caching.
The question remains: Why does --locked require extra steps when compared with --frozen?
Because --locked
has to validate that the lockfile is up-to-date, which requires accessing the project's metadata, which in your case requires building the project. --frozen
doesn't have to validate anything, so it doesn't need to build the metadata, since you're not installing the project.
Hi,
in my Dockerfile I do:
This works fine, and installs only the dependencies, not the project itself. But, I would like to check if the uv.lock file is actually up-to-date with the pyproject.toml file. So I added
--locked
. This doesn't work due to:error: the argument '--frozen' cannot be used with '--locked'
. So I remove --frozen, but that seems to change something with regards to build behavior, because I no longer manage to pass this step in my Docker container, I get:As context, this is a mixed python+rust project, with
maturin
as build-backend. The unexpected behavior here is that maturin is called in a way that demands aCargo.toml
file when I use--locked
vs--frozen
.What I would have wished for:
--locked
and--frozen
being non exclusive, as frozen seems to be more than just the instruction to not write the uv.lock file.--frozen
really only would skip the writing of theuv.lock
file, I would expect the above error to not occur when I substitute--frozen
with--locked
.