Skip to content

Commit

Permalink
[cli] add package manager installation method
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Xeonacid committed Jan 17, 2025
1 parent f7cc847 commit 6bc569e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/aptos/src/update/aptos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {},
}

Expand Down Expand Up @@ -173,6 +178,7 @@ impl BinaryUpdater for AptosUpdateTool {
pub enum InstallationMethod {
Source,
Homebrew,
PackageManager,
Other,
}

Expand All @@ -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
};
Expand Down

0 comments on commit 6bc569e

Please sign in to comment.