From ea7dcd02d2b5525a739450ec283aea29730fd275 Mon Sep 17 00:00:00 2001 From: Xeonacid Date: Fri, 17 Jan 2025 07:32:53 +0100 Subject: [PATCH] [cli] add package manager installation method If the binary locates at /usr/bin, refuse to use `aptos update aptos`, and redirect to package manager. This might be merged with the brew method. --- crates/aptos/src/update/aptos.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/aptos/src/update/aptos.rs b/crates/aptos/src/update/aptos.rs index 4a1d7e77d8ffd..5f3f281e6e54c 100644 --- a/crates/aptos/src/update/aptos.rs +++ b/crates/aptos/src/update/aptos.rs @@ -105,6 +105,11 @@ impl BinaryUpdater for AptosUpdateTool { "Detected this CLI comes from homebrew, use `brew upgrade aptos` instead" )); }, + InstallationMethod::PackageManager => { + return Err(anyhow!( + "Detected this CLI comes from a package manager, use your package manager to update instead" + )); + }, InstallationMethod::Other => {}, } @@ -173,6 +178,7 @@ impl BinaryUpdater for AptosUpdateTool { pub enum InstallationMethod { Source, Homebrew, + PackageManager, Other, } @@ -184,6 +190,8 @@ impl InstallationMethod { InstallationMethod::Homebrew } else if exe_path.to_string_lossy().contains("target") { InstallationMethod::Source + } else if exe_path.to_string_lossy().contains("/usr/bin") { + InstallationMethod::PackageManager } else { InstallationMethod::Other };