Skip to content

Instantly share code, notes, and snippets.

@Hoverbear
Created July 17, 2014 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hoverbear/831fc6b7eef6e825ef00 to your computer and use it in GitHub Desktop.
Save Hoverbear/831fc6b7eef6e825ef00 to your computer and use it in GitHub Desktop.
A little bit of handholding to get Rust going.

This script downloads the latest nightly and installs (or uninstalls) it as needed.

The steps are:

  • Download an extract Rust into a temporary directory.
  • Run the install.sh script with the options provided. (Like --uninstall)
  • Output necessary config options for the user.

To use:

  • Put the script code into any file. (Easiest way is curl $URL_FROM_RAW_BUTTON_OF_SCRIPT > rustup.sh)
  • chmod +x rustup.sh
  • ./rustup.sh to install.
#!/bin/bash
# The URL of the Rust nightlies.
URL="http://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz"
# The option that needs to be added to .bashrc or .zshrc
RC_OPTION='export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"'
function finish {
rm -rf $DIR
}
trap finish EXIT
echo
echo "Got options? Just pass them like you would the ./install.sh script."
echo "It's at https://raw.githubusercontent.com/rust-lang/rust/master/src/etc/install.sh"
echo "For example, --uninstall"
echo
DIR=$(mktemp -d -t)
echo "Downloading Rust from $URL and unpacking it to the temporary directory."
curl $URL | tar xzf - -C $DIR --strip-components=1
sudo bash $DIR/install.sh $@
echo
echo
if [ -a ~/.zshrc ]; then
echo "zsh user, you should run something like this:"
echo echo "\"$RC_OPTION\" >> ~/.zshrc"
fi
if [ -a ~/.bashrc ]; then
echo "bash user, you should run something like this:"
echo echo "\"$RC_OPTION\" >> ~/.bashrc"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment