Skip to content

Commit 6fd820d

Browse files
committed
Forwards PATH env to sudo
1 parent 61aa2e2 commit 6fd820d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/cli/src/lib.rs

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

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

207208
let (mut ext_dir, mut php_ini) = if let Some(install_dir) = self.install_dir {
@@ -328,8 +329,9 @@ impl Remove {
328329
use std::env::consts;
329330

330331
if !self.bypass_root_check {
332+
// use sudo and pass PATH for command like `cargo metadata` to keep working.
331333
#[cfg(unix)]
332-
sudo::escalate_if_needed().expect("failed to escalate root privileges.");
334+
sudo::with_env(&["PATH"]).expect("sudo failed, pass --bypass-root-check to disable.");
333335
}
334336

335337
let artifact = find_ext(self.manifest.as_ref())?;

0 commit comments

Comments
 (0)