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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Disable rustup self-updating #11722

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions images/macos/scripts/build/install-rust.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,49 @@
#!/bin/bash -e -o pipefail
################################################################################
## File: install-rust.sh
## Desc: Install Rust
## Desc: Install Rustup and Rust
################################################################################

source ~/utils/utils.sh

echo "Installing Rustup..."
brew_smart_install "rustup-init"
RUSTUP_VERSION="1.27.1" # Set the Rustup version to pin

echo "Installing Rust language..."
rustup-init -y --no-modify-path --default-toolchain=stable --profile=minimal
echo "Downloading Rustup version $RUSTUP_VERSION..."
curl -LO "https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/x86_64-apple-darwin/rustup-init"

# Check if the file was downloaded properly
if [[ ! -s rustup-init ]]; then
echo "Error: Rustup download failed. Check the URL or Rustup version."
exit 1
fi

echo "Making Rustup executable..."
chmod +x rustup-init

echo "Installing Rustup version $RUSTUP_VERSION..."
./rustup-init -y --no-modify-path || { echo "Rustup installation failed"; exit 1; }

# Ensure Rustup is available in PATH
export PATH="$HOME/.cargo/bin:$PATH"

echo "Verifying installed Rustup version..."
INSTALLED_VERSION=$(rustup --version | awk '{print $2}')
if [[ "$INSTALLED_VERSION" != "$RUSTUP_VERSION" ]]; then
echo "Error: Expected Rustup version $RUSTUP_VERSION but found $INSTALLED_VERSION"
exit 1
fi

echo "Setting Rust language to stable..."
rustup default stable
rustup show active-toolchain

echo "Initialize environment variables..."
CARGO_HOME=$HOME/.cargo

echo "Install common tools..."
echo "Disable Rustup self-updating"
rustup set auto-self-update disable

echo "Installing common tools..."
rustup component add rustfmt clippy

echo "Cleanup Cargo registry cached data..."
Expand Down