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 3 commits
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
55 changes: 30 additions & 25 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 ! command -v cargo &>/dev/null; do
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!"
jonaro00 marked this conversation as resolved.
Show resolved Hide resolved
}

_install_with_cargo() {
echo "Installing with cargo..."
cargo install --locked cargo-shuttle
}

Expand All @@ -167,19 +161,30 @@ _install_unsupported() {
return 0
fi

if ! command -v cargo &>/dev/null; then
if ! command -v rustup &>/dev/null; then
_install_rust_and_cargo
_install_with_cargo
jonaro00 marked this conversation as resolved.
Show resolved Hide resolved
return 0
else
echo "rustup was found, but cargo wasn't. Something is up with your install"
exit 1
fi
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]*)
echo "Installing pre-built binary..."
_install_binary
break
;;
[Nn]*)
read -r -p "Do you wish to attempt an install with 'cargo'? [Y/N] " yn </dev/tty
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'..."
_install_cargo
_install_with_cargo
break
;;
[Nn]*) exit ;;
Expand Down