Rust 自定义安装目录
本文最后更新于 64 天前,其中的信息可能已经有所发展或是发生改变。
内容目录

创建环境变量,记得应用环境变量:

export RUSTUP_HOME=/mnt/core/lib/rustup
export CARGO_HOME=/mnt/core/lib/cargo
export PATH=$PATH:$CARGO_HOME/bin

其中 RUSTUP_HOMECARGO_HOME 可以改成你喜欢的目录。

然后使用官方安装脚本安装即可:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

执行后输出如下:

madray@nas:~$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /mnt/core/lib/rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  /mnt/core/lib/cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /mnt/core/lib/cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/madray/.profile
  /home/madray/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:

   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>

可以看到 Rustup 将目录设置为了环境变量中的目录。

上一篇
下一篇