Skip to content

Commit bddc717

Browse files
committed
Block broken snap curl
When curl is installed with snap, it lacks permissions to write to the directories installers need (boukendesho/curl-snap#1), which breaks rustup-init.sh (#2948). To fix this, we error when the only available downloader is snap curl. We hit this problem in uv (astral-sh/uv#11849) and deployed a fix in our cargo-dist fork (astral-sh/cargo-dist#28). I've ported this fix to rustup. I've tested the change manually on my machine: * apt url works * snap curl and wget works * snap curl and no wget fails Unfortunately, snap doesn't run in docker so I can't provide a test script. Fixes #2948 Solves: * #924 (comment), though it's unclear if solves the original report too * #2775 (comment)
1 parent bd354c1 commit bddc717

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

rustup-init.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,22 @@ downloader() {
642642
local _status
643643
local _retry
644644
if check_cmd curl; then
645-
_dld=curl
645+
# Check if we have a broken snap curl
646+
# https://github.com/boukendesho/curl-snap/issues/1
647+
_curl_path=$(command -v curl)
648+
if echo "$_curl_path" | grep "/snap/" > /dev/null 2>&1; then
649+
if check_cmd wget; then
650+
_dld=wget
651+
else
652+
err "curl installed with snap cannot be used to install Rust"
653+
err "due to missing permissions. Please uninstall it and"
654+
err "reinstall curl with a different package manager (e.g., apt)."
655+
err "See https://github.com/boukendesho/curl-snap/issues/1"
656+
exit 1
657+
fi
658+
else
659+
_dld=curl
660+
fi
646661
elif check_cmd wget; then
647662
_dld=wget
648663
else

0 commit comments

Comments
 (0)