In Rust, by default, files are placed in $HOME/.cargo
and $HOME/.rustup
. Is there any way to override these defaults?
I am trying to debug an obscure issue and I want to try changing the file locations.
This is explained in the documentation:
rustup
allows you to customise your installation by setting the environment variablesCARGO_HOME
andRUSTUP_HOME
before running therustup-init
executable. As mentioned in the Environment Variables section,RUSTUP_HOME
sets the root rustup folder, which is used for storing installed toolchains and configuration options.CARGO_HOME
contains cache files used by cargo.
Don't forget to update the $PATH
or you won't be able to use the binaries. Also, if you want that setup to be permanent, export those variables from your shell configuration (e.g. .bashrc
or .zshrc
):
Note that you will need to ensure these environment variables are always set and that
CARGO_HOME/bin
is in the$PATH
environment variable when using the toolchain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With