Linux カーネルにおいても Rust が重要な言語となってきたので、
https://gigazine.net/news/20251211-linux-kernel-rust/

必然的に Raspberry Pi の環境においても Rust が使えるようにしておく必要がありますね。
https://rust-for-linux.com/

Rust は、Pythonと違ってコンパイラです。というわけで、Rust言語つまりそのコンパイラ等をインストールしてみます。

まずはソースからビルドしてみようと思いましたが、これを行おうとすると現状のマシンでは容量不足になるほど大きくなるので、ビルドも難しいということで断念しました。

そこで、バイナリデータをインストールするために、
https://rust-lang.github.io/rustup/installation/other.html
を参考にしました。

最初に、バージョン 1.91.1 のインストール時のログを示します。

$ 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

......................................

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

(このメッセージは deepL で翻訳しておきます。)

ここから======
Rustへようこそ!

これにより、Rustプログラミング言語の公式コンパイラと、
そのパッケージマネージャーであるCargoがダウンロードされ、インストールされます。

Rustupのメタデータとツールチェーンは、以下の場所にあるRustupホームディレクトリにインストールされます:

  /home/espiya/.rustup

これは RUSTUP_HOME 環境変数で変更できます。

Cargo のホームディレクトリは次の場所にあります:

  /home/espiya/.cargo

これは CARGO_HOME 環境変数で変更できます。

cargo、rustc、rustup などのコマンドは、以下の場所にある
Cargo の bin ディレクトリに追加されます:

  /home/espiya/.cargo/bin

このパスは、以下の場所にあるプロファイルファイルを変更することで、
PATH環境変数に追加されます:

  /home/espiya/.profile
  /home/espiya/.bashrc

いつでも rustup self uninstall でアンインストールでき、
これらの変更は元に戻ります。

現在のインストールオプション:


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

1) 標準インストールを続行する(デフォルト - Enterキーを押すだけ)
2) インストールをカスタマイズする
3) インストールをキャンセルする

======ここまで

(いったん 3 を入力してキャンセルします。)
>3

info: aborting installation
$

標準のインストール先は、

(ホームディレクトリ)/{.rustup,.cargo}

ですね。カスタマイズすると替えられるかもしれません。

改めてインストールしてみます。

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

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

info: profile set to 'default'
info: default host triple is aarch64-unknown-linux-gnu
info: syncing channel updates for 'stable-aarch64-unknown-linux-gnu'
info: latest update on 2025-11-10, rust version 1.91.1 (ed61e7d7e 2025-11-07)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 20.5 MiB /  20.5 MiB (100 %)  11.0 MiB/s in  3s
info: downloading component 'rust-std'
 27.0 MiB /  27.0 MiB (100 %)  11.0 MiB/s in  6s
info: downloading component 'rustc'
 58.3 MiB /  58.3 MiB (100 %)  11.0 MiB/s in 15s
info: downloading component 'rustfmt'
info: installing component 'cargo'
  9.7 MiB /   9.7 MiB (100 %)   7.1 MiB/s in  1s
info: installing component 'clippy'
info: installing component 'rust-docs'
 20.5 MiB /  20.5 MiB (100 %) 315.2 KiB/s in 46s
info: installing component 'rust-std'
 27.0 MiB /  27.0 MiB (100 %)   4.1 MiB/s in 15s
  9 IO-ops /   9 IO-ops (100 %)   0 IOPS in 23s ETA: Unknown
info: installing component 'rustc'
 58.3 MiB /  58.3 MiB (100 %)   3.9 MiB/s in 37s
  4 IO-ops /   4 IO-ops (100 %)   0 IOPS in 24s ETA: Unknown
info: installing component 'rustfmt'
info: default toolchain set to 'stable-aarch64-unknown-linux-gnu'

  stable-aarch64-unknown-linux-gnu installed - rustc 1.91.1 (ed61e7d7e 2025-11-07)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish
source $"($nu.home-path)/.cargo/env.nu"  # For nushell

$

環境設定をして、確認のために rustc を実行してみます。

$ . ~/.cargo/env
$

$ rustc --version
rustc 1.91.1 (ed61e7d7e 2025-11-07)
$

ちなみに、次回ログインすると、インスト-ル時に以下の様に修正されたので普通に使えます。

$ tail -1 ~/.bashrc
. "$HOME/.cargo/env"
$ tail -1 ~/.profile
. "$HOME/.cargo/env"
$

さて、なぜ古い rust 1.91.1 のインストールを取り上げたのか?それは、Rust が最近 1.92.0 にアップデートされたからです。
Rust では、再インストールしなくても「アップデートの方法」があることを示すためです。

インストールした Rust を使って、次の資料を参考に Rust 自身のバージョンアップを行ってみましょう。

Announcing Rust 1.92.0
https://blog.rust-lang.org/2025/12/11/Rust-1.92.0/


$ rustup update stable
info: syncing channel updates for 'stable-aarch64-unknown-linux-gnu'
info: latest update on 2025-12-11, rust version 1.92.0 (ded5c06cf 2025-12-08)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 20.5 MiB /  20.5 MiB (100 %)  11.0 MiB/s in  3s
info: downloading component 'rust-std'
 27.1 MiB /  27.1 MiB (100 %)  11.0 MiB/s in  6s
info: downloading component 'rustc'
 58.2 MiB /  58.2 MiB (100 %)  11.0 MiB/s in 16s
info: downloading component 'rustfmt'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'cargo'
  9.8 MiB /   9.8 MiB (100 %)   7.1 MiB/s in  1s
info: installing component 'clippy'
info: installing component 'rust-docs'
 20.5 MiB /  20.5 MiB (100 %)  72.0 KiB/s in  1m 28s
info: installing component 'rust-std'
 27.1 MiB /  27.1 MiB (100 %) 670.4 KiB/s in 34s
  5 IO-ops /   5 IO-ops (100 %)   0 IOPS in 25s ETA: Unknown
info: installing component 'rustc'
 58.2 MiB /  58.2 MiB (100 %)   4.0 MiB/s in 26s
  6 IO-ops /   6 IO-ops (100 %)   0 IOPS in  1m 15s ETA: Unknown
info: installing component 'rustfmt'

  stable-aarch64-unknown-linux-gnu updated - rustc 1.92.0 (ded5c06cf 2025-12-08) (from rustc 1.91.1 (ed61e7d7e 2025-11-07))

info: checking for self-update
$

アップデートできました。確認します。

$ which rustc
/home/espiya/.cargo/bin/rustc
$
$ rustc --version
rustc 1.92.0 (ded5c06cf 2025-12-08)
$

無事に 1.92.0 にアップデートされました。

前述のとおり、Rustのツールを利用するとローカルな自分のディレクトリの下にインストールされるのが特徴ですね。

一応テストしてみます。
https://doc.rust-jp.rs/rust-by-example-ja/hello.html
 

から、解説のコメントを除いて、Hello World のプログラムを作って sample00.rs ファイルとします。

$ cat sample00.rs
// This is the main function.
// main関数です
fn main() {
    // Statements here are executed when the compiled binary is called.
    // コンパイルされたバイナリが実行されるとこの関数が呼び出されます

    // Print text to the console.
    // コンソールに文字列を出力する
    println!("Hello World!");
}
$

$ rustc sample00.rs
$ ls

sample00  sample00.rs
$ ./sample00
Hello World!
$

無事に、コンパイルと実行ができました。使っているマシンが何かを自動判定しているので、Raspberry Pi でも問題無く動いていますね。コンパイラなのでコンパイルして生成された実行ファイルが正確に自分のマシンにあっていないといけないので、これで大丈夫です。

Rustは、インストールされた cargo が鍵となりそうですが機会があれば触ってみたいと思います。
使っているマシンが何かを自動判定してくれるので、Raspberry Pi でも問題無く動いていますね。
今後は、Coreutils
https://www.gnu.org/software/coreutils/

と同様に様々なライブラリ等が Rust で書かれて提供されるという流れになると思いますが、GnuとRustの関係も含めて、このような変化はなかなか無いので、ここ数年間の生成AIの変化と同様にその流れを見るのも楽しみです。