From cf138d1737b83203e799f786a4cb783ca7b00c93 Mon Sep 17 00:00:00 2001 From: Abraham Egnor Date: Tue, 18 Mar 2025 12:34:25 -0400 Subject: [PATCH] RUST-2181 Fix rustup installation on windows --- .evergreen/install-dependencies.sh | 9 +++++++++ .evergreen/unsymlink.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .evergreen/unsymlink.py diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index 4cb49e508..478899e4c 100755 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -21,6 +21,15 @@ for arg; do if [ $arg == "rust" ]; then curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path $DEFAULT_HOST_OPTIONS + # Cygwin has a bug with reporting symlink paths that breaks rustup; see + # https://github.com/rust-lang/rustup/issues/4239. This works around it by replacing the + # symlinks with copies. + if [ "Windows_NT" == "$OS" ]; then + pushd ${CARGO_HOME}/bin + python3 ../../.evergreen/unsymlink.py + popd + fi + # This file is not created by default on Windows echo 'export PATH="$PATH:${CARGO_HOME}/bin"' >>${CARGO_HOME}/env echo "export CARGO_NET_GIT_FETCH_WITH_CLI=true" >>${CARGO_HOME}/env diff --git a/.evergreen/unsymlink.py b/.evergreen/unsymlink.py new file mode 100644 index 000000000..5d199429e --- /dev/null +++ b/.evergreen/unsymlink.py @@ -0,0 +1,19 @@ +import os +import shutil + +found = [] +for entry in os.scandir(): + if not entry.is_symlink(): + print(f"Skipping {entry.name}: not a symlink") + continue + target = os.readlink(entry.name) + if target != "rustup.exe": + print(f"Skipping {entry.name}: not rustup.exe") + continue + print(f"Found {entry.name}") + found.append(entry.name) + +for name in found: + print(f"Replacing {name} symlink with copy") + os.remove(name) + shutil.copy2("rustup.exe", name) \ No newline at end of file