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 {
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+ }
You can’t perform that action at this time.
0 commit comments