From 0e738175c57d5789350b996b69c5713aac03835e Mon Sep 17 00:00:00 2001 From: Kevin Song Date: Wed, 11 Oct 2023 08:22:34 -0500 Subject: [PATCH] fix(install): do not use curl installed through snap (#5442) * fix: Do not install with snap-curl Snap-installed curl doesn't work: when trying to download files from GitHub, it either fails to download the file, or fails to write the output at all. Prevent a curl program which is installed with snap from being used to download starship. * Update install.sh * Minor changes to formatting and wording --- install/install.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/install/install.sh b/install/install.sh index 494a9cbf..80fe187a 100755 --- a/install/install.sh +++ b/install/install.sh @@ -40,6 +40,14 @@ has() { command -v "$1" 1>/dev/null 2>&1 } +curl_is_snap() { + curl_path="$(command -v curl)" + case "$curl_path" in + /snap/*) return 0 ;; + *) return 1 ;; + esac +} + # Make sure user is not using zsh or non-POSIX-mode bash, which can cause issues verify_shell_is_posix_or_exit() { if [ -n "${ZSH_VERSION+x}" ]; then @@ -55,7 +63,6 @@ verify_shell_is_posix_or_exit() { fi } -# Gets path to a temporary file, even if get_tmpfile() { suffix="$1" if has mktemp; then @@ -82,7 +89,13 @@ download() { file="$1" url="$2" - if has curl; then + if has curl && curl_is_snap; then + warn "curl installed through snap cannot download starship." + warn "See https://github.com/starship/starship/issues/5403 for details." + warn "Searching for other HTTP download programs..." + fi + + if has curl && ! curl_is_snap; then cmd="curl --fail --silent --location --output $file $url" elif has wget; then cmd="wget --quiet --output-document=$file $url"