Skip to content

Commit 2de3d2e

Browse files
committed
temp: write a log message
1 parent 6fd820d commit 2de3d2e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

crates/cli/src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ impl Install {
200200
)?;
201201

202202
if !self.bypass_root_check {
203-
// use sudo and pass PATH for command like `cargo metadata` to keep working.
204-
#[cfg(unix)]
205-
sudo::with_env(&["PATH"]).expect("sudo failed, pass --bypass-root-check to disable.");
203+
escalate_root();
206204
}
207205

208206
let (mut ext_dir, mut php_ini) = if let Some(install_dir) = self.install_dir {
@@ -329,9 +327,7 @@ impl Remove {
329327
use std::env::consts;
330328

331329
if !self.bypass_root_check {
332-
// use sudo and pass PATH for command like `cargo metadata` to keep working.
333-
#[cfg(unix)]
334-
sudo::with_env(&["PATH"]).expect("sudo failed, pass --bypass-root-check to disable.");
330+
escalate_root();
335331
}
336332

337333
let artifact = find_ext(self.manifest.as_ref())?;
@@ -586,3 +582,13 @@ fn build_ext(
586582

587583
bail!("Failed to retrieve extension path from artifact")
588584
}
585+
586+
fn escalate_root() {
587+
// use sudo and pass PATH for command like `cargo metadata` to keep working.
588+
#[cfg(unix)]
589+
{
590+
println!("Using sudo...");
591+
sudo::with_env(&["CARGO", "PATH"])
592+
.expect("sudo failed, pass --bypass-root-check to disable.");
593+
}
594+
}

0 commit comments

Comments
 (0)