Skip to content

Instantly share code, notes, and snippets.

@akorobov
Created March 19, 2017 19:15
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save akorobov/9a1b66d8faf1481540048e8206e4e32d to your computer and use it in GitHub Desktop.
Save akorobov/9a1b66d8faf1481540048e8206e4e32d to your computer and use it in GitHub Desktop.
Installing rustup in different location

To install rustup in different directory (i.e. /opt):

  1. install rustup in custom directory pointed to by RUSTUP_HOME envvar:
curl https://sh.rustup.rs -sSf | sudo RUSTUP_HOME=/opt/rustup sh -s -- -y
  1. select default tool chain
sudo RUSTUP_HOME=/opt/rustup rustup default stable
  1. fix $HOME/.cargo permissions after rustup installation (it ends up being owned as root)
sudo chown -R <username> .cargo/
  1. (optional,used by racer) add rust source
sudo RUSTUP_HOME=/opt/rustup rustup component add rust-src
  1. set up rust-specific env variables
export RUSTUP_HOME=/opt/rustup
export PATH=$HOME/.cargo/bin:$PATH
export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src"
  1. add RUSTUP_HOME to Defaults env_keep list in /etc/sudoersto retain this variable for sudo commands (i.e. updating rustup/rust toolchains)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment