File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -200,9 +200,7 @@ impl Install {
200
200
) ?;
201
201
202
202
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 ( ) ;
206
204
}
207
205
208
206
let ( mut ext_dir, mut php_ini) = if let Some ( install_dir) = self . install_dir {
@@ -329,9 +327,7 @@ impl Remove {
329
327
use std:: env:: consts;
330
328
331
329
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 ( ) ;
335
331
}
336
332
337
333
let artifact = find_ext ( self . manifest . as_ref ( ) ) ?;
@@ -586,3 +582,13 @@ fn build_ext(
586
582
587
583
bail ! ( "Failed to retrieve extension path from artifact" )
588
584
}
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
+ }
You can’t perform that action at this time.
0 commit comments