Error installing Rust with Rustup on Raspberry Pi


I am installing Rust, using Rustup on a Pi. I have done this many times, and it has always just worked. Not this time. I am at a loss.

I get this error towards the end of the process stable-aarch64-unknown-linux-gnu installed - (error reading rustc version)

When I try to run cargo help after I get: error: command failed: 'cargo': No such file or directory (os error 2)

cargo is on my path, executable programme:

patch@patchbox:~ $ which cargo
patch@patchbox:~ $ ls -l `which cargo`
-rwxr-xr-x 14 patch patch 13370420 Oct 13 22:45 /home/patch/.cargo/bin/cargo
patch@patchbox:~ $ file `which cargo`
/home/patch/.cargo/bin/cargo: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/, for GNU/Linux 3.2.101, with debug_info, not stripped
patch@patchbox:~ $ 

This is the tail end of source ./

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 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"
patch@patchbox:~ $ source "$HOME/.cargo/env"
patch@patchbox:~ $ cargo help  
error: command failed: 'cargo': No such file or directory (os error 2)

It may be that PatchboxOS is 32-bit

I am unsure if that makes a difference.

What does $HOME/.cargo/bin contain? (That’s where the executable for the cargo command[1] should be located.)

(example output, I’m not sure what the actual expected list of binaries would be)

$ ls $HOME/.cargo/bin
cargo          cargo-clippy   cargo-fmt      clippy-driver  rust-analyzer
rust-gdb       rust-gdbgui    rust-lldb      rustc          rustdoc
rustfmt        rustup

Ah, wait, I might have misinterpreted the error message to mean that “cargo” wasn’t found, whereas the os error might come from a different file :thinking: I’m not actually sure though. Gotta love error messages…

  1. I’m using this wording, since it’s not the cargo binary itself, but technically a rustup wrapper ↩︎

Googling suggests that “PatchboxOS” may be 32-bit. Searching for the error message gave this thread in which the user ended up using a different target triple. This tutorial seems to hint a similar thing. One features “armv7-unknown-linux-gnueabihf”, the other “arm-unknown-linux-gnueabihf”, not sure yet what’s the difference or which one you’d need.

I think this is a misleading error message. I'm sure I have seen it in cases where the executable file does actually exist but it is built for the wrong architecture.

If you are using a 32 bit OS something has gone wrong with the architecture detection and it has installed a 64 bit executable stable-aarch64-unknown-linux-gnu as your message log show. It's a while since I have used a Pi but I think I had that problem at some point as well with Raspbian. Especially a problem if you have a 64 bit kernel but 32 bit user land. A known problem: rustup installs incorrect version when 64 bit kernel enabled in 32bit OS. · Issue #3307 · rust-lang/rustup · GitHub

That one

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.