Skip to content

Commit

Permalink
fix(install): do not use curl installed through snap (#5442)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
chipbuster committed Oct 11, 2023
1 parent 9450af9 commit 0e73817
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions install/install.sh
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 0e73817

Please sign in to comment.