Skip to content

Instantly share code, notes, and snippets.

@kondanta
Forked from akorobov/rustup-install.md
Last active June 5, 2019 13:14
Show Gist options
  • Save kondanta/a73a7a461d8ff17eee2c12edc8b7cde3 to your computer and use it in GitHub Desktop.
Save kondanta/a73a7a461d8ff17eee2c12edc8b7cde3 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 | RUSTUP_HOME=/home/kondanta/tools/rust/rustup CARGO_HOME=/home/kondanta/tools/rust/cargo sh -s -- -y
  1. select default tool chain
RUSTUP_HOME=/opt/rustup rustup default stable
  1. It was related root owning the folder but its not the case now.

  2. (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