I always like to try out different programming languages. This time, Rust. I have long been a fan of manual memory management, which enable you to squeeze every single performance from the hardware.
However, installing Rust is not as simple as I think. Here is some weird things I encountered. I am not talking about programming in Rust, but solely installing the Rust toolchain.
Always read the Arch wiki before diving into infinite googling.
I use Artix Linux, which is an Arch based system without
systemd. Normally, an Arch user would install the package via
or some kind of AUR helper like
paru. For the majority of my use
cases, it never causes any problems. (I personally use paru to replace
pacman, most functions are identical, except paru can also install
package from AUR. If you don't have paru, just replace it with pacman,
everything will run.)
own package manager, or dependency manager. But Rust has its installer
In normal use case, if you are not cross compiling to other platforms. Installing Rust from pacman is fine.
What you have to do is:
paru -S rust
This installs the complete rust toolchain.
I was experimenting with webassembly (wasm). Somehow compiling Rust into wasm is considered as cross compiling to other platforms.
I compiled my Rust project with:
cargo build --target wasm32-unknown-unknown
An error occured.
The compiler told me it "can't find crate for `std`". It suggests me to run this:
rustup target add wasm32-unknown-unknown
But guess what, I don't have rustup at all. How am I going to run this thing?
I did not think it is a big deal at first. If I am missing a command, I would just install it using pacman, right?
paru -S rustup
It conflicts with rust. If I have to install rustup, I would have to uninstall rust first.
What the hell? (I still have no idea what rustup is at that moment.)
So I googled rustup. And it brought me to the installation page of Rust. It says "Using rustup (Recommended)", and provides a script to do so.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
It looks suspicious. It is telling me to run a random script from a link. And what it does is "download rustup and install Rust", the content must be absolutely "safe". But I already have rust installed, what do I do?
I removed my rust from pacman.
paru -R rust
It said rust-analyzer, and rust-src depended on rust. Rust-analyzer is the language server of Rust. I definitely did not want it to be uninstalled, but for the sake of rustup, I removed all three of them.
I ruthlessly ran the script provided by the official Rust site. Luckily, it really was a Rust installer. I had to choose from stable or nightly. As a man lives on the edge of Emacs HEAD, I without a doubt chose stable. :D
It installed all the binaries into
~/.cargo/bin. I have to add it to
the path so I can use it with ease. With zsh, it is simple, I edited
.zshrc. (This does not work in bash.)
path+=($HOME'/.cargo/bin') export PATH
I happily opened my
main.rs and tried to make a simple hello
world. Emacs told me that
rust-analyzer cannot be found, so no lsp.
Oh yes, I removed it myself. Let's install it back.
paru -S rust-analyzer
What? It depends on rust and rust-src. Okay, the binaries that rustup installed cannot act as a dependecies for pacman, I understand that.
I visited the rust-analyzer page, went to the Arch Linux section. It told me to use pacman to install.
There must be a way to install it via rustup. But, it is only available in the "nightly" toolchain. Fuck.
Fine, I switched to the nightly one. Installed rust-analyzer.
rustup +nightly component add rust-analyzer-preview
No, rust-analyzer is still not in my path. Why?
However, in contrast to component add clippy or component add rustfmt, this does not actually place a rust-analyzer binary in ~/.cargo/bin
Why the Rust team has to make things so complicated?
I had enough. Suddenly, I thought I should look up in the Arch
wiki. Turn out that every single issue I encountered was detailedly
documented in the Arch wiki. It even suggests the best way to install
Rust, use pacman to install rustup, do not use the script. This does
not even require you to edit the PATH, since pacman manage everything
for you in
It looks like a shit post. But it really bother me the whole morning. I think myself is somewhat experienced in using commands, but still pissed off because of a lot of unclear instructions and different ways of doing the same thing (installing the Rust toolchain). Different way leads to different issues which is not supposed to have.
If installing Rust directly from pacman has the limitation of not able
to cross compile, why does this option exist in the first place? I
don't see installing rustup to install rust using significantly more
resources or taking up more spaces. Also, why would the Rust team
think running a script using
curl would be a secure idea to get the