Repository navigation
Conversation
Member
|
#13953 appears to be an unrelated (merged) PR, not a bug report. Did you mean to link something else? |
tdhopper
force-pushed
the
fix/no-cache-env-var-precedence
branch
from
June 17, 2026 16:29
f1e017f to
8c60746
Compare
zanieb
reviewed
Jun 17, 2026
CacheSettings::resolve() used || to combine the env var and config file values for no-cache. This meant if the config file set no-cache = true, the env var could only agree — UV_NO_CACHE=false had no effect. Changed CacheArgs.no_cache from bool to Option<bool> so we can distinguish 'explicitly set to false' from 'not set'. The resolve() method now uses .combine() (same pattern as offline, native-tls, etc.) which gives the env var/CLI arg precedence when set, falling back to the config file value otherwise. Fixes the precedence order documented at: https://docs.astral.sh/uv/concepts/configuration-files/
tdhopper
force-pushed
the
fix/no-cache-env-var-precedence
branch
from
June 17, 2026 17:17
8c60746 to
b7b3674
Compare
Replace the Option<bool> + BoolishValueParser approach on --no-cache with the idiomatic flag pair pattern used throughout the codebase (e.g. --offline/--no-offline). Changes: - Revert --no-cache to a plain bool flag, add hidden --cache counterpart with overrides_with for mutual exclusion - Remove env = EnvVars::UV_NO_CACHE from the clap attribute; handle the env var manually in CacheSettings::resolve() via new env_no_cache() helper that uses parse_boolish_environment_variable - Resolution chain: flag(no_cache, cache) > UV_NO_CACHE env var > config file > default (false) - Update unit tests to use the new bool/bool field layout - Update help text snapshots (no more [=<NO_CACHE>], [env:], [possible values:])
- Fix flag() semantic inversion: use flag(cache, no_cache, "cache") with .map(|cache| !cache) so the error message correctly says --cache and --no-cache, matching the convention of all other flag pairs. - Fix UV_NO_CACHE being ignored in pre-resolution paths: the discovery cache in lib.rs and TryFrom<CacheArgs> in uv-dev now also check the UV_NO_CACHE env var, not just the CLI flag. - Add [env: UV_NO_CACHE=] to the doc comment so it appears in help text, matching the pattern used by --offline [env: UV_OFFLINE=]. - Remove flaky env-var-dependent unit tests (env::set_var is unsafe and not thread-safe with parallel test execution). Keep deterministic flag + config tests. Env var behavior is covered by integration tests. - Restore help.rs and upgrade.rs snapshots to match upstream format.
All three call sites that resolve no_cache (CacheSettings::resolve, TryFrom<CacheArgs>, and discovery_cache in lib.rs) now share the same flag pair + env var logic via CacheArgs::resolved_no_cache(). Previously, TryFrom and discovery_cache ignored the --cache flag and silently swallowed invalid UV_NO_CACHE values. Now all paths respect both flags and produce consistent parse errors.
uv test inventory changesThis PR changes the tests when compared with the latest
|
…n test - Add no_cache EnvFlag to EnvironmentOptions, matching the UV_OFFLINE pattern - Pass EnvironmentOptions to CacheSettings::resolve() (1 caller updated) - Remove standalone env_no_cache() helper - Fix broken cross-crate doc link in resolved_no_cache() - Fix exit(2) -> exit(1) to match parse_failure convention - Add integration test proving UV_NO_CACHE=false overrides no-cache=true in config
Author
🙈 Claude slop, sorry... |
Author
|
@zanieb I'd love to get eyes on this again when you have time, thanks! |
This was referenced Jul 15, 2026
zaniebot
pushed a commit
to astral-sh/uv-dev
that referenced
this pull request
Oct 7, 2026
Exercise the configuration override reported in astral-sh#19895, including explicit CLI and opposite-environment controls.
zaniebot
pushed a commit
to astral-sh/uv-dev
that referenced
this pull request
Oct 7, 2026
Retain the environment value separately so it can override no-cache in configuration, while the existing command-line flag remains authoritative. This narrows the precedence repair proposed by Tim Hopper in astral-sh#19895 without adding a new flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CacheSettings::resolve()used||to combine the CLI/env var and config file values forno-cache, so if the config file setno-cache = true,UV_NO_CACHE=falsehad no effect (false || true == true).The fix uses the same flag pair pattern as
--offline/--no-offline:--cacheflag withoverrides_with, paired with--no-cacheenv = UV_NO_CACHEfrom the clap attribute — the env var is now read manually viaenv_no_cache()usingparse_boolish_environment_variable, matching howUV_OFFLINEis handledresolve()usesflag(cache, no_cache, "cache").map(|cache| !cache).combine(env_no_cache()).combine(workspace).unwrap_or(false)[env: UV_NO_CACHE=]to the doc comment so it still appears in--helpdiscovery_cacheinlib.rs,TryFrom<CacheArgs>inuv-dev) also checkUV_NO_CACHETest plan
--cacheflag overrides config,--no-cacheflag overrides configcargo clippyclean onuv-cache,uv,uv-devcargo test -- help::(14 tests pass)cargo test -- upgrade::upgrade_helppassescargo test -- show_settings::resolve_uv_tomlpassesuv --no-cache pip --help,uv --no-cache --version,uv --cache --version,uv -n pip --help,UV_NO_CACHE=false uv --versionall workno-cache = trueinuv.toml,UV_NO_CACHE=falsecorrectly resolvesno_cache: false