Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(installer): always check for cargo install first #1610

Merged
merged 5 commits into from Feb 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 42 additions & 37 deletions install.sh
Expand Up @@ -112,7 +112,6 @@ _install_mac() {
}

_install_binary() {
echo "Installing pre-built binary..."
case "$OSTYPE" in
linux*) target="x86_64-unknown-linux-musl" ;;
darwin*) target="x86_64-apple-darwin" ;;
Expand All @@ -133,28 +132,23 @@ _install_binary() {
fi
}

_install_cargo() {
echo "Attempting install with cargo"
if ! command -v cargo &>/dev/null; then
echo "cargo not found! Attempting to install Rust and cargo via rustup"
if command -v rustup &>/dev/null; then
echo "rustup was found, but cargo wasn't. Something is up with your install"
exit 1
fi
while true; do
read -r -p "cargo not found! Do you wish to attempt to install Rust and cargo via rustup? [Y/N] " yn </dev/tty
case $yn in
[Yy]*)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s
source "$HOME/.cargo/env"
;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
done
echo "rustup installed! Attempting cargo install"
fi
_install_rust_and_cargo() {
while true; do
jonaro00 marked this conversation as resolved.
Show resolved Hide resolved
read -r -p "Do you wish to attempt to install Rust and Cargo via rustup? [Y/N] " yn </dev/tty
case $yn in
[Yy]*)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s
source "$HOME/.cargo/env"
;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
done
echo "rustup installed! Installing with cargo"
_install_cargo
jonaro00 marked this conversation as resolved.
Show resolved Hide resolved
}

_install_cargo() {
cargo install --locked cargo-shuttle
}

Expand All @@ -167,28 +161,39 @@ _install_unsupported() {
return 0
fi

while true; do
read -r -p "Do you wish to attempt to install the pre-built binary? [Y/N] " yn </dev/tty
case $yn in
[Yy]*)
_install_binary
break
;;
[Nn]*)
read -r -p "Do you wish to attempt an install with 'cargo'? [Y/N] " yn </dev/tty
if ! command -v cargo &>/dev/null; then
if ! command -v rustup &>/dev/null; then
_install_rust_and_cargo
return 0
else
echo "rustup was found, but cargo wasn't. Something is up with your install"
exit 1
fi
else
while true; do
read -r -p "Do you wish to attempt an install with cargo? [Y/N] " yn </dev/tty
case $yn in
[Yy]*)
echo "Installing with 'cargo'..."
echo "Installing with cargo..."
_install_cargo
break
;;
[Nn]*) exit ;;
[Nn]*)
read -r -p "Do you wish to attempt to install the pre-built binary? [Y/N] " yn </dev/tty
case $yn in
[Yy]*)
echo "Installing pre-built binary..."
_install_binary
break
;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
;;
*) echo "Please answer yes or no." ;;
esac
;;
*) echo "Please answer yes or no." ;;
esac
done
done
fi
}

if command -v cargo-shuttle &>/dev/null; then
Expand Down