@@ -10,12 +10,12 @@ use super::engine::Engine;
1010use super :: shared:: * ;
1111use crate :: config:: bool_from_envvar;
1212use crate :: errors:: Result ;
13- use crate :: extensions:: CommandExt ;
13+ use crate :: extensions:: { CommandExt , SafeCommand } ;
1414use crate :: file:: { self , PathExt , ToUtf8 } ;
1515use crate :: rustc:: { self , QualifiedToolchain , VersionMetaExt } ;
1616use crate :: shell:: { MessageInfo , Stream } ;
17- use crate :: temp;
1817use crate :: TargetTriple ;
18+ use crate :: { temp, CargoVariant } ;
1919
2020// prevent further commands from running if we handled
2121// a signal earlier, and the volume is exited.
@@ -667,6 +667,7 @@ impl QualifiedToolchain {
667667pub ( crate ) fn run (
668668 options : DockerOptions ,
669669 paths : DockerPaths ,
670+ mut cmd : SafeCommand ,
670671 args : & [ String ] ,
671672 subcommand : Option < crate :: Subcommand > ,
672673 msg_info : & mut MessageInfo ,
@@ -895,34 +896,38 @@ pub(crate) fn run(
895896 }
896897 }
897898
898- // `clean` doesn't handle symlinks: it will just unlink the target
899- // directory, so we should just substitute it our target directory
900- // for it. we'll still have the same end behavior
901- let mut final_args = vec ! [ ] ;
902- let mut iter = args. iter ( ) . cloned ( ) ;
903- let mut has_target_dir = false ;
904- while let Some ( arg) = iter. next ( ) {
905- if arg == "--target-dir" {
906- has_target_dir = true ;
907- final_args. push ( arg) ;
908- if iter. next ( ) . is_some ( ) {
909- final_args. push ( target_dir. clone ( ) ) ;
910- }
911- } else if arg. starts_with ( "--target-dir=" ) {
912- has_target_dir = true ;
913- if arg. split_once ( '=' ) . is_some ( ) {
914- final_args. push ( format ! ( "--target-dir={target_dir}" ) ) ;
899+ if options. cargo_variant != CargoVariant :: None {
900+ // `clean` doesn't handle symlinks: it will just unlink the target
901+ // directory, so we should just substitute it our target directory
902+ // for it. we'll still have the same end behavior
903+ let mut final_args = vec ! [ ] ;
904+ let mut iter = args. iter ( ) . cloned ( ) ;
905+ let mut has_target_dir = false ;
906+ while let Some ( arg) = iter. next ( ) {
907+ if arg == "--target-dir" {
908+ has_target_dir = true ;
909+ final_args. push ( arg) ;
910+ if iter. next ( ) . is_some ( ) {
911+ final_args. push ( target_dir. clone ( ) ) ;
912+ }
913+ } else if arg. starts_with ( "--target-dir=" ) {
914+ has_target_dir = true ;
915+ if arg. split_once ( '=' ) . is_some ( ) {
916+ final_args. push ( format ! ( "--target-dir={target_dir}" ) ) ;
917+ }
918+ } else {
919+ final_args. push ( arg) ;
915920 }
916- } else {
917- final_args. push ( arg) ;
918921 }
922+ if !has_target_dir && subcommand. map_or ( true , |s| s. needs_target_in_command ( ) ) {
923+ final_args. push ( "--target-dir" . to_owned ( ) ) ;
924+ final_args. push ( target_dir. clone ( ) ) ;
925+ }
926+
927+ cmd. args ( final_args) ;
928+ } else {
929+ cmd. args ( args) ;
919930 }
920- if !has_target_dir && subcommand. map_or ( true , |s| s. needs_target_in_command ( ) ) {
921- final_args. push ( "--target-dir" . to_owned ( ) ) ;
922- final_args. push ( target_dir. clone ( ) ) ;
923- }
924- let mut cmd = options. cargo_variant . safe_command ( ) ;
925- cmd. args ( final_args) ;
926931
927932 // 5. create symlinks for copied data
928933 let mut symlink = vec ! [ "set -e pipefail" . to_owned( ) ] ;
0 commit comments