最近需要在Raspberry Pi (树莓派)上写个小东西,

环境配置

硬件:Raspberry 3B+

系统:

  • Raspbain lite
  • Kernel version: 5.10
  • 发布时间: October 30th 2021

一键安装

一键安装脚本,如下:

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:

/home/pi/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

/home/pi/.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:

/home/pi/.cargo/bin

This path will then be added to your PATH environment variable by

modifying the profile files located at:

/home/pi/.profile

/home/pi/.bashrc

You can uninstall at any time with rustup self uninstall and

these changes will be reverted.

Current installation options:

default host triple: armv7-unknown-linux-gnueabihf

  1. default toolchain: stable (default)
  2. profile: default

modify PATH variable: yes

1) Proceed with installation (default)

2) Customize installation

3) Cancel installation

1

info: profile set to ‘default’

info: default host triple is armv7-unknown-linux-gnueabihf

info: syncing channel updates for ‘stable-armv7-unknown-linux-gnueabihf’

info: latest update on 2021-12-02, rust version 1.57.0 (f1edd0429 2021-11-29)

info: downloading component ‘cargo’

info: downloading component ‘clippy’

info: downloading component ‘rust-std’

22.6 MiB / 22.6 MiB (100 %) 9.4 MiB/s in 4s ETA: 0s

info: downloading component ‘rustc’

91.2 MiB / 91.2 MiB (100 %) 9.3 MiB/s in 12s ETA: 0s

info: downloading component ‘rustfmt’

info: installing component ‘cargo’

5.7 MiB / 5.7 MiB (100 %) 3.9 MiB/s in 1s ETA: 0s

info: installing component ‘clippy’

info: installing component ‘rust-std’

22.6 MiB / 22.6 MiB (100 %) 1.7 MiB/s in 9s ETA: 0s

info: installing component ‘rustc’

91.2 MiB / 91.2 MiB (100 %) 2.6 MiB/s in 34s ETA: 0s

info: installing component ‘rustfmt’

info: default toolchain set to ‘stable-armv7-unknown-linux-gnueabihf’

stable-armv7-unknown-linux-gnueabihf installed - rustc 1.57.0 (f1edd0429 2021-11-29)

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, run:

source $HOME/.cargo/env

安装完后需要注意的配置文件

  • $HOME/.cargo/bin
  • $HOME/.cargo/env

重启

运行命令:sudo reboot

或者

不重启,运行下面的命令,无需注销和再次登录就能设置正确的路径。

source $HOME/.cargo/env

更新

以后更新就直接运行:

rustup update

参考

https://rustup.rs