On Windows, can the ...\xyz\.cargo (example) directory be moved after installation by simply moving the .cargo directory, updating CARGO_HOME to the new location, and updating the PATH with the new .cargo\bin location?
Thank You
On Windows, can the ...\xyz\.cargo (example) directory be moved after installation by simply moving the .cargo directory, updating CARGO_HOME to the new location, and updating the PATH with the new .cargo\bin location?
Thank You
Yes. For example, if you move the .cargo directory from C:\Users\xyz\.cargo to D:\Rust\.cargo, and then update the CARGO_HOME environment variable to point to the new location, as well as update your PATH to include D:\Rust\.cargo\bin, Cargo will run using the new directory.
The files in .cargo on Windows are hard links. If the links are copied, will the destination have the files themselves and no longer the hard links?
Presumably you'll need to use a utility that can preserve hard links to perform the copy. I did a quick search and rumor has it that robocopy supports hard links -- though I haven't tried it myself.
Yes, I'll simply reinstall. Thanks!
I don’t think robocopy supports preserving hard links. As far as i know it has the /SL option, which preserves symbolic links by copying the links themselves instead of duplicating the files or folders they point to.
Thanks. When links are involved, I avoid the risk and the complexity of using special copy tool etc. (especially because I'm only starting out with Rust). I simply reinstalled. Easy enough.
yes, rustup made it very easy to setup a rust development environment.
but realistically, only the config.toml in your $CARGO_HOME needs to be migrated and preserved, because that's personalized, all other contents in $CARGO_HOME can be easily reinstalled or reproduced.
the registry index and crate sources are just locally cached artifacts which can be downloaded from the server on demand.
the bin directory contains either the rustup toolchain binaries or third party programs installed with cargo install command.
the tools of rustup components are actually just renamed copy/link of rustup.exe, which is renamed from rustup-init.exe when you first installed it. all of these are the exact same binary, but behaves differently based on the program name (similar to busybox).
if you find some of them are missing from $CARGO_HOME/bin, you can just copy or link rustup.exe there. if you don't remember the tool names, you can run rustup-init --default-toolchain=none, it will re-install all the required shims without downloading anything online. then you can use your installed rust toolchain just like before, the shim binaries will use the configurations in your $RUSTUP_HOME to automatically find and select your default toolchain.
for third party programs, just make a note of the packages you installed, you can always run cargo install on the new machine, presumably with explicit package version numbers and the --locked flag so you know they will work the same.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.