How to build `rustup` from source

I am trying to build rustup (not rustup-init) from source. I have the rustup repo checked out, but when I run cargo run from within the repo, it runs rustup-init, not rustup. I can see why this is happening - the repo contains only one binary target, which is rustup-init.

So how can I build rustup?

It’s all the same file. The way it behaves depends on the name of the binary. A bit sneaky, similar to how busybox works. If you rename it rustup it should behave as rustup. It you name it cargo or rustc or cargo-clippy, cargo-fmt, cargo-miri, clippy-driver, rls, rust-gdb, rustdoc, rustfmt, etc… (non-exhaustive list), it becomes a shim that identifies the current active default toolchain, relevant overrides for the current directory, parses the additional +toolchain argument if present, and then calls the correct respective installed binary with the remaining arguments.


…which is documented at the very beginning of that file.


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.