Skip to content

UV_LOCKED enables both --check and --locked #16517

@AlexVndnblcke

Description

@AlexVndnblcke

Summary

After an update to the latest version 0.9.6, a recent change in #16322 enables both flags --check and --locked when UV_LOCKED is set as environment variable.

Minimal example:

uv lock  # OK
uv lock --check  # OK
uv lock --locked # OK
UV_LOCKED=true uv lock  #FAIL

This yields the following error:

error: the argument '--check' cannot be used with '--locked'

Usage: uv lock --check

The culprit seems to be that env variable UV_LOCKED is shared between the --check and --locked flag (see diff)

uv-cli/src/lib.rs:3716-3732

    /// Check if the lockfile is up-to-date.
    ///
    /// Asserts that the `uv.lock` would remain unchanged after a resolution. If the lockfile is
    /// missing or needs to be updated, uv will exit with an error.
    ///
    /// Equivalent to `--locked`.
    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check_exists", "upgrade", "locked"])]
    pub check: bool,

    /// Check if the lockfile is up-to-date.
    ///
    /// Asserts that the `uv.lock` would remain unchanged after a resolution. If the lockfile is
    /// missing or needs to be updated, uv will exit with an error.
    ///
    /// Equivalent to `--check`.
    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check_exists", "upgrade", "check"], hide = true)]
    pub locked: bool,

So I assume clap enables both conflicting flags when UV_LOCKED is being used.

Platform

Darwin 24.6.0 arm64

Version

0.9.6

Python version

3.11.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions