Improve message when updater receipt is for a different uv executable (#9487)

Attempts to improve confusing messaging in cases like
https://github.com/astral-sh/uv/issues/6774#issuecomment-2504950681,
when the receipt is for a different uv executable.

```
❯ cargo run --all-features -q -- self update
warning: Self-update is only available for uv binaries installed via the standalone installation scripts.

The current executable is at `/Users/zb/workspace/uv/target/debug/uv` but the standalone installer was used to install uv to `/Users/zb/.cargo`. Are multiple copies of uv installed?
```

Requires https://github.com/axodotdev/axoupdater/pull/221
Closes https://github.com/astral-sh/uv/issues/6774
This commit is contained in:
Zanie Blue 2024-12-03 19:26:32 -06:00 committed by GitHub
parent 1ecdc1a31e
commit ae033e2d3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 8 deletions

4
Cargo.lock generated
View file

@ -276,9 +276,9 @@ dependencies = [
[[package]] [[package]]
name = "axoupdater" name = "axoupdater"
version = "0.8.1" version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb8d8889305a413a040f281197bb2f8982a1d25c9696707cab350e3cc780ba5" checksum = "a70b7d3a9ea86ef8d17dada23f2c42518ed4b75dd6a8ff761f8988b448db8454"
dependencies = [ dependencies = [
"axoasset", "axoasset",
"axoprocess", "axoprocess",

View file

@ -76,7 +76,7 @@ async-compression = { version = "0.4.12", features = ["bzip2", "gzip", "xz", "zs
async-trait = { version = "0.1.82" } async-trait = { version = "0.1.82" }
async_http_range_reader = { version = "0.9.1" } async_http_range_reader = { version = "0.9.1" }
async_zip = { git = "https://github.com/charliermarsh/rs-async-zip", rev = "c909fda63fcafe4af496a07bfda28a5aae97e58d", features = ["deflate", "tokio"] } async_zip = { git = "https://github.com/charliermarsh/rs-async-zip", rev = "c909fda63fcafe4af496a07bfda28a5aae97e58d", features = ["deflate", "tokio"] }
axoupdater = { version = "0.8.0", default-features = false } axoupdater = { version = "0.8.2", default-features = false }
backoff = { version = "0.4.0" } backoff = { version = "0.4.0" }
base64 = { version = "0.22.1" } base64 = { version = "0.22.1" }
bitflags = { version = "2.6.0" } bitflags = { version = "2.6.0" }

View file

@ -6,6 +6,7 @@ use owo_colors::OwoColorize;
use tracing::debug; use tracing::debug;
use uv_client::WrappedReqwestError; use uv_client::WrappedReqwestError;
use uv_fs::Simplified;
use crate::commands::ExitStatus; use crate::commands::ExitStatus;
use crate::printer::Printer; use crate::printer::Printer;
@ -48,9 +49,9 @@ pub(crate) async fn self_update(
// uv binaries installed, and the current binary was _not_ installed via the standalone // uv binaries installed, and the current binary was _not_ installed via the standalone
// installation scripts. // installation scripts.
if !updater.check_receipt_is_for_this_executable()? { if !updater.check_receipt_is_for_this_executable()? {
debug!( let current_exe = std::env::current_exe()?;
"receipt is not for this executable; assuming uv was installed via a package manager" let receipt_prefix = updater.install_prefix_root()?;
);
writeln!( writeln!(
printer.stderr(), printer.stderr(),
"{}", "{}",
@ -59,10 +60,12 @@ pub(crate) async fn self_update(
"{}{} Self-update is only available for uv binaries installed via the standalone installation scripts.", "{}{} Self-update is only available for uv binaries installed via the standalone installation scripts.",
"\n", "\n",
"\n", "\n",
"If you installed uv with pip, brew, or another package manager, update uv with `pip install --upgrade`, `brew upgrade`, or similar." "The current executable is at `{}` but the standalone installer was used to install uv to `{}`. Are multiple copies of uv installed?"
), ),
"warning".yellow().bold(), "warning".yellow().bold(),
":".bold() ":".bold(),
current_exe.simplified_display().bold().cyan(),
receipt_prefix.simplified_display().bold().cyan()
) )
)?; )?;
return Ok(ExitStatus::Error); return Ok(ExitStatus::Error);