To install rustup in different directory (i.e. /opt):
- 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- select default tool chain
sudo RUSTUP_HOME=/opt/rustup rustup default stable- fix
$HOME/.cargopermissions afterrustupinstallation (it ends up being owned as root)
sudo chown -R <username> .cargo/- (optional,used by racer) add rust source
sudo RUSTUP_HOME=/opt/rustup rustup component add rust-src- 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"- add
RUSTUP_HOMEtoDefaultsenv_keeplist in/etc/sudoersto retain this variable forsudocommands (i.e. updating rustup/rust toolchains)