rustrust-cargorustup

What is the difference between binaries in ~/.rustup vs ~/.cargo?


I just installed Rust with rustup on MacOS and noticed that there are two rustc and two cargo binaries:

Their versions are exactly the same, but diff shows there exists some difference. So why are there two different rustc (cargo) binaries and which one should I use?


Solution

  • The reason there are two files named rustc is because rustup is a toolchain multiplexer. It lets you install many versions of Rust and easily switch between them.

    The binary installed at ~/.cargo/bin/rustc proxies to the current toolchain that you have selected. Each installed compiler is kept under the toolchains directory.

    Although the compiler in the toolchains directory appears to be a smaller file, that's only because it's dynamically linked instead of statically linked.

    More information can be found on rustup's README.