Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding Rust installation default paths `$HOME/.cargo` and `$HOME/.rustup`

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.

like image 846
Martin Ellison Avatar asked Sep 03 '19 05:09

Martin Ellison


1 Answers

This is explained in the documentation:

rustup allows you to customise your installation by setting the environment variables CARGO_HOME and RUSTUP_HOME before running the rustup-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.

like image 169
Boiethios Avatar answered Nov 07 '22 20:11

Boiethios