rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.16k stars 888 forks source link

improve custom installation experience / docs #2479

Open phrohdoh opened 4 years ago

phrohdoh commented 4 years ago

Describe the problem you are trying to solve

Install Rust tooling in custom locations on my file system via env vars.

Describe the solution you'd like

I'd like rustup to not error if installed somewhere other than ~/.cargo.

Notes

$ echo $RUSTUP_HOME $CARGO_HOME $CARGO_INSTALL_ROOT
/Users/taryn/.data/rustup /Users/taryn/.data/cargo /Users/taryn/.bin

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | RUSTUP_HOME="$RUSTUP_HOME" CARGO_HOME="$CARGO_HOME" sh

[..snip..]

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /Users/taryn/.data/rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /Users/taryn/.data/cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /Users/taryn/.data/cargo/bin

[..snip..]

  stable installed - rustc 1.46.0 (04488afe3 2020-08-24)

Rust is installed now. Great!

To get started you need Cargo's bin directory (/Users/taryn/.data/cargo/bin) in
your PATH
environment variable.

To configure your current shell run source /Users/taryn/.data/cargo/env

$ which rustup cargo rustc
/Users/taryn/.data/cargo/bin/rustup
/Users/taryn/.data/cargo/bin/cargo
/Users/taryn/.data/cargo/bin/rustc

$ rustup self update
error: rustup is not installed at '/Users/taryn/.cargo'

If rustup must be installed at ~/.cargo, why have the home env vars at all? If I need to do something else that hasn't been shown here, the docs don't make that clear to me. AFAICT I've done everything correctly but cannot use Rust tooling.

kinnison commented 4 years ago

Do you have the environment variables set in your shell setup by default? If not, rustup won't understand what's going on. Those variables have to be set all the time for it to work.

phrohdoh commented 4 years ago

Yes, they are set in my ~/.zshrc.

kinnison commented 4 years ago

If CARGO_HOME is set properly then rustup self update will honour it. (Since that's how we run our test suites) You might want to double check your environment in a fresh shell.