Skip to content

Instantly share code, notes, and snippets.

@lmmx
Last active May 19, 2025 13:22
Show Gist options
  • Save lmmx/3c8ee86a3b4de74fe3bc0215d552edfa to your computer and use it in GitHub Desktop.
Save lmmx/3c8ee86a3b4de74fe3bc0215d552edfa to your computer and use it in GitHub Desktop.
Uninstall old Rust nightly versions
# Keep the latest nightly and remove older dated nightlies
LATEST_DATE=$(rustup toolchain list | grep 'nightly-[0-9]' | sed 's/nightly-\([0-9-]*\).*/\1/' | sort -r | head -n 1)
# If we found dated nightlies, remove all except the most recent one
if [ -n "$LATEST_DATE" ]; then
for toolchain in $(rustup toolchain list | grep 'nightly-[0-9]' | grep -v "$LATEST_DATE"); do
echo "Removing old nightly: $toolchain"
rustup toolchain uninstall "$toolchain"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment