diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index cc08ae5f99f0e..25037bd0faaa9 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -771,7 +771,8 @@ def build_bootstrap(self, color): elif color == "never": args.append("--color=never") - run(args, env=env, verbose=self.verbose) + # Run this from the source directory so cargo finds .cargo/config + run(args, env=env, verbose=self.verbose, cwd=self.rust_root) def build_triple(self): """Build triple as in LLVM diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 14e8ebd6876b4..6a07ac6b007cb 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1325,6 +1325,9 @@ impl<'a> Builder<'a> { ) -> Cargo { let mut cargo = Command::new(&self.initial_cargo); let out_dir = self.stage_out(compiler, mode); + // Run cargo from the source root so it can find .cargo/config. + // This matters when using vendoring and the working directory is outside the repository. + cargo.current_dir(&self.src); // Codegen backends are not yet tracked by -Zbinary-dep-depinfo, // so we need to explicitly clear out if they've been updated.