How can I move the RUST tools installation dir?

128 Views Asked by At

I mistakenly installed RUST in my "src" tree. It works but I'd like to move it to someplace under my local AppData directory like "%LOCALAPPDATA%\Rust" or maybe "%LOCALAPPDATA%\Rust\Stable". I can't see where the "self" or "update" options of "rustup" have an option to do that. Is there an option to do that or do I do a full uninstall and re-install? I think that the documentation implies that I can set the "RUSTUP_HOME" and "CARGO_HOME" environment variables before installing RUST and that will cause "rustup" or the installer to put the executables into "%CARGO_HOME%\bin". Am I reading that right?

Version info:

C:\>rustup --version
rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.73.0 (cc66ad468 2023-10-03)`

Environment vars:

C:\Users\*JOE_USER*>echo "%CARGO_HOME%" && echo "%RUSTUP_HOME%"
"C:\Users\*JOE_USER*\OneDrive\Documents\Src\.cargo"
"C:\Users\*JOE_USER*\OneDrive\Documents\Src\.rustup"

Here's where the multiple renamed versions of "RUSTUP" are:

Directory of C:\Users\*JOE_USER*\OneDrive\Documents\Src\.cargo\bin

08/11/2023  09:38 PM    <DIR>          .
03/01/2023  10:06 AM    <DIR>          ..
08/11/2023  08:57 PM         8,594,944 cargo-clippy.exe
08/11/2023  08:57 PM         8,594,944 cargo-fmt.exe
08/11/2023  08:57 PM         8,594,944 cargo-miri.exe
08/11/2023  08:57 PM         8,594,944 cargo.exe
08/11/2023  08:57 PM         8,594,944 clippy-driver.exe
08/11/2023  08:57 PM         8,594,944 rls.exe
08/11/2023  08:57 PM         8,594,944 rust-analyzer.exe
08/11/2023  08:57 PM         8,594,944 rust-gdb.exe
08/11/2023  08:57 PM         8,594,944 rust-gdbgui.exe
08/11/2023  08:57 PM         8,594,944 rust-lldb.exe
08/11/2023  08:57 PM         8,594,944 rustc.exe
08/11/2023  08:57 PM         8,594,944 rustdoc.exe
08/11/2023  08:57 PM         8,594,944 rustfmt.exe
08/11/2023  08:57 PM         8,594,944 rustup.exe

Here's where the actual executables are:

Directory of C:\Users\*JOE_USER*\OneDrive\Documents\Src\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin

10/16/2023  02:51 PM        22,269,440 cargo.exe
10/16/2023  02:51 PM         9,035,776 clippy-driver.exe
10/16/2023  02:51 PM           770,048 cargo-clippy.exe
10/16/2023  02:52 PM         4,706,304 test-bdd24cd8003a6271.pdb
10/16/2023  02:52 PM         6,868,992 std-287abad1c0bdb9b8.pdb
10/16/2023  02:52 PM        60,534,784 rustc_driver-ecc82c9d925511c8.pdb
10/16/2023  02:52 PM               265 rust-windbg.cmd
10/16/2023  02:52 PM         3,575,808 rustc_main-0b34c7ab06f9785c.pdb
10/16/2023  02:52 PM           112,128 rustc.exe
10/16/2023  02:52 PM         8,693,248 rustdoc.exe
10/16/2023  02:52 PM         1,699,328 test-bdd24cd8003a6271.dll
10/16/2023  02:52 PM        11,128,320 std-287abad1c0bdb9b8.dll
10/16/2023  02:52 PM       133,861,888 rustc_driver-ecc82c9d925511c8.dll
10/16/2023  02:52 PM    <DIR>          ..
10/16/2023  02:52 PM         1,354,240 cargo-fmt.exe
10/16/2023  02:52 PM         5,092,352 rustfmt.exe
10/16/2023  02:52 PM    <DIR>          .
1

There are 1 best solutions below

1
On BEST ANSWER

You can just move the .cargo and .rustup directories and set RUSTUP_HOME and CARGO_HOME accordingly. You might also need to adjust PATH and similar variables.