From 9fefb47242e22402f0a31d5ed5e7f3dd279d9dc9 Mon Sep 17 00:00:00 2001 From: Gideon <87426140+GideonBear@users.noreply.github.com> Date: Wed, 25 Jun 2025 13:24:07 +0200 Subject: [PATCH] Catch secondary uv self-update error (#1201) --- src/steps/generic.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 1d8420c0..24d04406 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -1399,11 +1399,24 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> { // After 0.4.25 (inclusive), running `uv self` succeeds regardless of the // feature gate, so the above approach won't work. // - // We run `uv self update` directly, if it outputs: + // We run `uv self update` directly, and ignore an error if it outputs: // - // "uv was installed through an external package manager, and self-update is not available. Please use your package manager to update uv.\n" + // "error: uv was installed through an external package manager, and self-update is not available. Please use your package manager to update uv.\n" + // + // or: + // + // " + // error: Self-update is only available for uv binaries installed via the standalone installation scripts. + // + // If you installed uv with pip, brew, or another package manager, update uv with `pip install --upgrade`, `brew upgrade`, or similar. + // " + // + // These two error messages can both occur, in different situations. - const ERROR_MSG: &str = "uv was installed through an external package manager, and self-update is not available. Please use your package manager to update uv."; + const ERROR_MSGS: [&str; 2] = [ + "uv was installed through an external package manager, and self-update is not available. Please use your package manager to update uv.", + "Self-update is only available for uv binaries installed via the standalone installation scripts.", + ]; let output = ctx .run_type() @@ -1418,7 +1431,7 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> { }; let stderr = std::str::from_utf8(&output.stderr).expect("output should be UTF-8 encoded"); - if stderr.contains(ERROR_MSG) { + if ERROR_MSGS.iter().any(|&n| stderr.contains(n)) { // Feature `self-update` is disabled, nothing to do. } else { // Feature is enabled, flush the captured output so that users know we did the self-update.