File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed 
src/bootstrap/src/core/builder Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -590,18 +590,30 @@ impl StepDescription {
590590        // Attempt to resolve paths to be relative to the builder source directory. 
591591        let  mut  paths:  Vec < PathBuf >  = paths
592592            . iter ( ) 
593-             . map ( |p| { 
593+             . map ( |original_path| { 
594+                 let  mut  path = original_path. clone ( ) ; 
595+ 
596+                 // Someone could run `x <cmd> <path>` from a different repository than the source 
597+                 // directory. 
598+                 // In that case, we should not try to resolve the paths relative to the working 
599+                 // directory, but rather relative to the source directory. 
600+                 // So we forcefully "relocate" the path to the source directory here. 
601+                 if  !path. is_absolute ( )  { 
602+                     path = builder. src . join ( path) ; 
603+                 } 
604+ 
594605                // If the path does not exist, it may represent the name of a Step, such as `tidy` in `x test tidy` 
595-                 if  !p. exists ( )  { 
596-                     return  p. clone ( ) ; 
606+                 if  !path. exists ( )  { 
607+                     // Use the original path here 
608+                     return  original_path. clone ( ) ; 
597609                } 
598610
599611                // Make the path absolute, strip the prefix, and convert to a PathBuf. 
600-                 match  std:: path:: absolute ( p )  { 
612+                 match  std:: path:: absolute ( & path )  { 
601613                    Ok ( p)  => p. strip_prefix ( & builder. src ) . unwrap_or ( & p) . to_path_buf ( ) , 
602614                    Err ( e)  => { 
603615                        eprintln ! ( "ERROR: {e:?}" ) ; 
604-                         panic ! ( "Due to the above error, failed to resolve path: {p :?}" ) ; 
616+                         panic ! ( "Due to the above error, failed to resolve path: {path :?}" ) ; 
605617                    } 
606618                } 
607619            } ) 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments