Skip to content

Commit cf138d1

Browse files
committed
RUST-2181 Fix rustup installation on windows
1 parent 1adb457 commit cf138d1

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.evergreen/install-dependencies.sh

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ for arg; do
2121
if [ $arg == "rust" ]; then
2222
curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path $DEFAULT_HOST_OPTIONS
2323

24+
# Cygwin has a bug with reporting symlink paths that breaks rustup; see
25+
# https://github.com/rust-lang/rustup/issues/4239. This works around it by replacing the
26+
# symlinks with copies.
27+
if [ "Windows_NT" == "$OS" ]; then
28+
pushd ${CARGO_HOME}/bin
29+
python3 ../../.evergreen/unsymlink.py
30+
popd
31+
fi
32+
2433
# This file is not created by default on Windows
2534
echo 'export PATH="$PATH:${CARGO_HOME}/bin"' >>${CARGO_HOME}/env
2635
echo "export CARGO_NET_GIT_FETCH_WITH_CLI=true" >>${CARGO_HOME}/env

.evergreen/unsymlink.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
import shutil
3+
4+
found = []
5+
for entry in os.scandir():
6+
if not entry.is_symlink():
7+
print(f"Skipping {entry.name}: not a symlink")
8+
continue
9+
target = os.readlink(entry.name)
10+
if target != "rustup.exe":
11+
print(f"Skipping {entry.name}: not rustup.exe")
12+
continue
13+
print(f"Found {entry.name}")
14+
found.append(entry.name)
15+
16+
for name in found:
17+
print(f"Replacing {name} symlink with copy")
18+
os.remove(name)
19+
shutil.copy2("rustup.exe", name)

0 commit comments

Comments
 (0)