rustup 安装到哪里?

Where does rustup install itself to?

我知道 rustuprustccargo 二进制文件安装到 ~/.cargo/bin,但是它将 rustup 可执行文件安装到哪里?据我所知,这在任何文档中都没有解释,运行 安装程序也没有告诉你。如果可能的话,我想避免将它安装到我的主目录以外的任何地方。如果有区别,我正在使用 macOS。

通过默认,rustup 也安装到您的主目录:

$ which rustup
/Users/shep/.cargo/bin/rustup

documentation states:

rustup installs rustc, cargo, rustup and other standard tools to Cargo's bin directory. On Unix it is located at $HOME/.cargo/bin and on Windows at %USERPROFILE%\.cargo\bin. This is the same directory that cargo install will install Rust programs and Cargo plugins.

goes on to describe how to change the defaults:

rustup allows you to customise your installation by setting the environment variables CARGO_HOME and RUSTUP_HOME before running the rustup-init executable. As mentioned in the Environment Variables section, RUSTUP_HOME sets the root rustup folder, which is used for storing installed toolchains and configuration options. CARGO_HOME contains cache files used by cargo.

如果您使用 Chocolatey 安装 Rust,它会安装到 C:\ProgramData\chocolatey\bin(至少当我使用它时)。

为了验证它是由 Chocolatey 安装的,在 PowerShell window 运行 choco list --local-only 中查看返回的列表是否包含 Rust。

您可以在管理员 PowerShell window.

中通过 运行ning choco uninstall rust 卸载 Chocolatey 的 Rust 实例

在我的例子中,rustup(连同它安装的工具链)位于一个名为 .rustup 的文件夹中,该文件夹与 .cargo 处于同一级别