Hanging on installing component 'rustc'

I tried to install rust on a Raspi Zero 2W following this command:
curl https://sh.rustup.rs -sSf | sh
from:
https://www.howtogeek.com/replace-default-linux-commands-with-these-alternatives/
but the curl hung when it got to:
info: installing component 'rustc'
71.3 MiB / 83.7 MiB ( 85 %) 499.2 KiB/s in 1m 18s ETA: 25s

so I uninstalled (I hoped) whatever might have made it through, using
rustup self uninstall
which went through and ended:
"info: rustup is uninstalled"

Next, I followed instructions here:
https://rustmeup.com/using-rust-with-raspberry-pi
and tried
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Again it hung, this time at 92% and seven seconds.
When it hangs, the green LED on the Pi0-2W just flashes on and off steadily - none of the irregular flickering that indicates processing.

That was on a Raspi Zero 2W, so next I tried the same installation method on a Raspi Zero W
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
and it installed fine:

rustc --version
shows
rustc 1.82.0 (f6e511eec 2024-10-15)

Any advice on what I might try to get past the hang on installing component 'rustc', please?

I should mention that the hangs were for several minutes, both pi zeros were up to date, and they are running bookworm.

Thanks

It only has 512MB RAM, right? By default rustup will use more memory than that while unpacking the archives. You might want to look at the discussion on OOM installing rustc-dev with 1GB of memory · Issue #3125 · rust-lang/rustup · GitHub In particular try setting RUSTUP_IO_THREADS=1 and maybe set RUSTUP_UNPACK_RAM to a low integer. I believe if you set RUSTUP_UNPACK_RAM to something lower than the minimum necessary it will pick the minimum necessary value.

Thanks for replying.

The install just succeeded after I increased the swap file from 512MiB to 1024MiB.

The odd thing is that it installed on the Pi0 W but not on the Pi0 2W. Speculating wildly, could it be that if the unpacking uses all four cores, it outruns available memory on the 2W but the single thread on the W keeps it within bounds? I dunno.

For future reference, where would I have set those RUSTUP_.... values? Sorry for my ignorance, I'm working on overcoming it.

The Rust compiler is not really designed to work on such low-end hardware. You will keep running out of memory, and even the builds that won't fail will take horribly long.

You should use cross-compilation. Build the binaries on a 200W+ machine, and copy them to the Pi afterwards. Cross-compilation can be annoying to configure, but you'll still save time compared to horrible build times on the Pi directly.

I was installing rust because I wanted to compile eza. Eventually it compiled on the pi0 2W, but, as you say it took a very long time. I got on with other things and didn't notice the time, but a couple of hours, I think. And eza worked.

Meanwhile I did the same on a pi 5, and it was done in a matter of minutes.

I think I'm going to learn Rust, so I'll install it on a Windows machine for snappier performance.