From 9512179900a254dbba83fcb39e281e4d2b24d1aa Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Fri, 24 Mar 2023 11:14:30 -0500 Subject: [PATCH] 1.68 added the creation of a `build/host` symlink that points to the `build/` directory. However, this directory does not always exist. The directory is normally created when downloading the bootstrap tools, but if the user manually configures `build.rustc` and `build.cargo` then the build will fail. This fixes the issue be creating the directory junction target if it does not exist. It's not an issue on non-Windows platforms, because they use symlinks (which are allowed to point to non-existent entities). --- src/bootstrap/util.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 9a6aaffe22b24..1cab583892450 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -185,6 +185,11 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> { Ok(s.as_ref().encode_wide().chain(Some(0)).collect()) } + if !target.exists() { + // Windows requires that the target of a junction exists. + fs::create_dir_all(&target)?; + } + // We're using low-level APIs to create the junction, and these are more // picky about paths. For example, forward slashes cannot be used as a // path separator, so we should try to canonicalize the path first.