在树莓派 4 上安装 Rust 后无法运行货物

use*_*674 15 path rust rust-cargo rustup raspberry-pi4

我尝试使用推荐的安装脚本在 Raspberrypi 4 上安装 rust:

pi@raspberrypi:/tmp $ curl https://sh.rustup.rs -sSf | sh
Run Code Online (Sandbox Code Playgroud)

但重启后,cargo找不到:

pi@raspberrypi:~ $ cargo
error: command failed: 'cargo'
error: caused by: No such file or directory (os error 2)
Run Code Online (Sandbox Code Playgroud)

这可能与安装过程中报告的情况有关(error reading rustc version)(完整的安装日志位于底部):

info: default toolchain set to 'stable-aarch64-unknown-linux-gnu'

  stable-aarch64-unknown-linux-gnu installed - (error reading rustc version)
Run Code Online (Sandbox Code Playgroud)

以下是完整的安装日志:

pi@raspberrypi:/tmp $ curl https://sh.rustup.rs -sSf | 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: aarch64-unknown-linux-gnu
     default toolchain: stable (default)
               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 aarch64-unknown-linux-gnu
info: syncing channel updates for 'stable-aarch64-unknown-linux-gnu'
info: latest update on 2021-03-25, rust version 1.51.0 (2fd73fabe 2021-03-23)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 15.0 MiB /  15.0 MiB (100 %)   6.6 MiB/s in  2s ETA:  0s
info: downloading component 'rust-std'
 26.3 MiB /  26.3 MiB (100 %)  10.2 MiB/s in  4s ETA:  0s
info: downloading component 'rustc'
 76.9 MiB /  76.9 MiB (100 %)  10.1 MiB/s in 12s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: using up to 500.0 MiB of RAM to unpack components
  5.3 MiB /   5.3 MiB (100 %)   5.1 MiB/s in  1s ETA:  0s
info: installing component 'clippy'
info: installing component 'rust-docs'
 15.0 MiB /  15.0 MiB (100 %)   2.3 MiB/s in  6s ETA:  0s
info: installing component 'rust-std'
 26.3 MiB /  26.3 MiB (100 %)   4.5 MiB/s in  9s ETA:  0s
info: installing component 'rustc'
 76.9 MiB /  76.9 MiB (100 %)   5.0 MiB/s in 15s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-aarch64-unknown-linux-gnu'

  stable-aarch64-unknown-linux-gnu installed - (error reading rustc version)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

To configure your current shell, run:
source $HOME/.cargo/env
pi@raspberrypi:~ $ cargo
error: command failed: 'cargo'
error: caused by: No such file or directory (os error 2)
Run Code Online (Sandbox Code Playgroud)

纳米/home/pi/.profile

if [ -n "$BASH_VERSION" ]; then
        # include .bashrc if it exists
        if [ -f "$HOME/.bashrc" ]; then
            . "$HOME/.bashrc"
        fi
    fi
    


# set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
    fi
    
    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/.local/bin" ] ; then
        PATH="$HOME/.local/bin:$PATH"
    fi
    source "$HOME/.cargo/env"
Run Code Online (Sandbox Code Playgroud)

也在 /home/pi/.bashrc 中:

 source "$HOME/.cargo/env"
Run Code Online (Sandbox Code Playgroud)

uname -a

Linux raspberrypi 5.10.17-v8+ #1403 SMP PREEMPT Mon Feb 22 11:37:54 GMT 2021 aarch64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

小智 24

当询问安装选项时,选择 2) 自定义安装,然后选择“默认主机三重?” 输入“arm-unknown-linux-gnueabihf”

它与32位/64位有关。