rust - 覆盖 Rust 安装默认路径 `$HOME/.cargo` 和 `$HOME/.rustup`

标签 rust rust-cargo rustup

在 Rust 中,默认情况下,文件放在 $HOME/.cargo$HOME/.rustup 中。有什么方法可以覆盖这些默认值吗?

我正在尝试调试一个模糊的问题,我想尝试更改文件位置。

最佳答案

这解释了in the documentation :

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.

不要忘记更新 $PATH 否则您将无法使用二进制文件。此外,如果您希望该设置是永久性的,请从您的 shell 配置中导出这些变量(例如 .bashrc.zshrc):

Note that you will need to ensure these environment variables are always set and that CARGO_HOME/bin is in the $PATH environment variable when using the toolchain.

关于rust - 覆盖 Rust 安装默认路径 `$HOME/.cargo` 和 `$HOME/.rustup`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57765424/

相关文章:

rust - 语法问题函数返回函数不清楚

rust - Cargo.toml中的[dependencies]和[dependencies.dependency-name]有什么区别?

rust - 用于 lib 的 Cargo.toml

rust - 无法从 conda 环境中的 jupyter 服务器连接到 rust 内核

curl - Rustup 说 libcurl 中不支持或禁用协议(protocol) "https"

winapi - 为什么从 Rust 调用 SystemParametersInfo 来设置壁纸会将其设置为黑色?

testing - 在文档测试中使用本地模块时出错

rust - 具有相同分隔符的并排宏重复

rust - 如何在函数调用时显示编译器警告?

rust - 如何使用 Rust 构建 32 位静态二进制文件?