Rustツールチェーンのインストール
動作確認済みシステム Debian 11
必要なパッケージをインストールします。
apt update
apt install curl git gcc binutils make pkg-config
バージョンに1.73.0を、インストール先に/usr/local/lib/rustを指定し、OSの全ユーザが使えるようにします。
RUST_TOOLCHAIN=1.73.0
export RUST_HOME=/usr/local/lib/rust
export RUSTUP_HOME=${RUST_HOME}/rustup
export CARGO_HOME=${RUST_HOME}/cargo
mkdir -p $RUST_HOME
chmod 0755 $RUST_HOME
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "${RUST_TOOLCHAIN}" --no-modify-path
info: downloading installer
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for '1.73.0-x86_64-unknown-linux-gnu'
info: latest update on 2023-10-05, rust version 1.73.0 (cc66ad468 2023-10-03)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 13.8 MiB /  13.8 MiB (100 %)  11.4 MiB/s in  1s ETA:  0s
info: downloading component 'rust-std'
 24.7 MiB /  24.7 MiB (100 %)  11.4 MiB/s in  2s ETA:  0s
info: downloading component 'rustc'
 61.6 MiB /  61.6 MiB (100 %)  11.4 MiB/s in  5s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 13.8 MiB /  13.8 MiB (100 %)   5.7 MiB/s in  2s ETA:  0s
info: installing component 'rust-std'
 24.7 MiB /  24.7 MiB (100 %)  11.3 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 61.6 MiB /  61.6 MiB (100 %)  12.3 MiB/s in  5s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to '1.73.0-x86_64-unknown-linux-gnu'
  1.73.0-x86_64-unknown-linux-gnu installed - rustc 1.73.0 (cc66ad468 2023-10-03)
Rust is installed now. Great!
To get started you need Cargo's bin directory (/usr/local/lib/rust/cargo/bin) 
in your PATH
environment variable. This has not been done automatically.
To configure your current shell, run:
source "/usr/local/lib/rust/cargo/env"
OSの全ユーザーがRustツールチェーンを使えるように、/etc/profile.d/以下に新規ファイルを作成して、環境変数の設定を書き込みます。
vi /etc/profile.d/rust.sh
export RUST_HOME=/usr/local/lib/rust
export RUSTUP_HOME=${RUST_HOME}/rustup
export CARGO_HOME=${RUST_HOME}/cargo
source ${CARGO_HOME}/env
ログインしなおすか、再起動するかすれば、rustcやcargoといったコマンドが使えるようになります。
