Skip to content

Conversation

@charliermarsh
Copy link

Summary

We frequently see user reports in uv (e.g., astral-sh/uv#13385) related to the fact that environment variables set to fasely values still report as conflicting. Here's a minimal example from #5591 (comment):

use clap::Parser;

#[derive(Debug, Parser)]
pub struct Args {
    /// Don't resolve.
    #[arg(long, env = "FROZEN", value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check"])]
    frozen: bool,

    /// Check that the resolution is valid.
    #[arg(long, env = "CHECK", value_parser = clap::builder::BoolishValueParser::new())]
    check: bool,
}

fn main() {
    let args = Args::parse();
    println!("Args: {args:?}");
}
$ CHECK=0 mini-uv --frozen
error: the argument '--frozen' cannot be used with '--check'

Usage: clap-conflicts --frozen

For more information, try '--help'.

This PR modifies the parsing to treat "set from environment" behavior as non-explicit if the value matches the default.

Closes #5591.

@charliermarsh charliermarsh changed the title Treat environment variables set to their default value as non-explicit fix: Don't treat default env vals as explicit Jan 5, 2026
@epage
Copy link
Member

epage commented Jan 5, 2026

@charliermarsh I appreciate the interest in moving this forward but this is not a change to be made lightly and the way forward is design discussions on the issue and not a PR, per our contrib guidelines

@epage epage closed this Jan 5, 2026
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.

Setting flag argument's env var to flase still flagged as conflicting

2 participants