I have been looking at my .cargo/bin directory.
The way I understand it, the programs "cargo", "rustc", "rustfmt"..., etc are symlinks to "rustup".
There also is a file called "rustup-init"
The files "rustup" and "rustup-init" are both identical according to diff.
Why are they no just the same file hardlinked?
1 Like
At a guess it's due to details of the install/update process.
//! During install (as `rustup-init`):
//!
//! * copy the self exe to $CARGO_HOME/bin
//! * hardlink rustc, etc to *that*
//! * update the PATH in a system-specific way
//! * run the equivalent of `rustup default stable`
//!
//! During upgrade (`rustup self upgrade`):
//!
//! * download rustup-init to $CARGO_HOME/bin/rustup-init
//! * run rustup-init with appropriate flags to indicate
//! this is a self-upgrade
//! * rustup-init copies bins and hardlinks into place. On windows
//! this happens *after* the upgrade command exits successfully.
(The guess based purely on the comments. I have no rustup-init
file.)
The comments are wrong. It doesn't hardlink rustc, etc.
Anyway, I found out what happens...
These comments on the update() function.
/// Because it's again difficult for rustup-init to delete itself
/// (and on windows this process will not be running to do it),
/// rustup-init is stored in `CARGO_HOME`/bin, and then deleted next
/// time rustup runs.
and so I ran 'rustup update" and now the "rustup-init" file is gone.
So many workarounds in the code for this language it makes my head spin.
Self install and update is always incredibly fraught and fiddly. Windows makes it worse than it needs to be, but it's never actually easy.
2 Likes