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 | RUSTUP_HOME=/home/kondanta/tools/rust/rustup CARGO_HOME=/home/kondanta/tools/rust/cargo sh -s -- -y- select default tool chain
RUSTUP_HOME=/opt/rustup rustup default stable-
It was related root owning the folder but its not the case now.
-
(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)