Skip to content

Commit d1642e3

Browse files
committed
escalate sudo before cargo_manifest
Left a note in the implementation
1 parent 2de3d2e commit d1642e3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/cli/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,14 @@ impl Remove {
326326
pub fn handle(self) -> CrateResult {
327327
use std::env::consts;
328328

329+
let artifact = find_ext(self.manifest.as_ref())?;
330+
331+
// Must be called after cargo_manifest call in find_path. Though we are setting PATHso that
332+
// sudo can find cargo but cargo_manifest doesn't use PATH to locate cargo!
329333
if !self.bypass_root_check {
330334
escalate_root();
331335
}
332336

333-
let artifact = find_ext(self.manifest.as_ref())?;
334-
335337
let (mut ext_path, mut php_ini) = if let Some(install_dir) = self.install_dir {
336338
(install_dir, None)
337339
} else {
@@ -587,8 +589,7 @@ fn escalate_root() {
587589
// use sudo and pass PATH for command like `cargo metadata` to keep working.
588590
#[cfg(unix)]
589591
{
590-
println!("Using sudo...");
591592
sudo::with_env(&["CARGO", "PATH"])
592-
.expect("sudo failed, pass --bypass-root-check to disable.");
593+
.expect("sudo failed! Use --bypass-root-check to disable.");
593594
}
594595
}

0 commit comments

Comments
 (0)