Installing Rust on Fedora: 1.98 and a domestic crates mirror
sudo dnf install cargo rustrustc --versioncargo --versionrustc 1.98.1 (48a229cea 2026-09-01) (Fedora 1.98.1-1.fc45)cargo 1.98.1 (797e8a9bc 2026-08-05) (Fedora 1.98.1-1.fc45)cargo pulls rustc in as a dependency, but installing rust explicitly documents the intent. Both land in /usr/bin.
First project
Section titled “First project”cargo new hellocd hellocargo runcargo new creates Cargo.toml and src/main.rs; cargo run compiles and executes.
cargo build --release./target/release/helloPointing crates.io at a mirror
Section titled “Pointing crates.io at a mirror”cargo fetches from index.crates.io by default, which is slow here:
mkdir -p ~/.cargocat > ~/.cargo/config.toml <<'EOF'[source.crates-io]replace-with = 'tuna'
[source.tuna]registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"EOFThe sparse+ prefix matters — it uses the HTTP index instead of cloning git, which is an order of magnitude faster.
Repository build versus rustup
Section titled “Repository build versus rustup”This is the part that needs saying clearly:
| You want | Use |
|---|---|
| build existing projects, CI | dnf install cargo rust, upgrades follow Fedora |
| a pinned release | rustup |
| nightly / beta toolchains | rustup (the repository carries stable only) |
cross compilation, rustup target add | rustup |
| full isolation | the rust:1.98 container |
The repository build has no rustup, so no toolchain switching and no rustup component add rustfmt clippy — those are separate Fedora packages.
With rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shsource ~/.cargo/envrustup toolchain install nightlyrustup default nightlyDomestic acceleration for rustup downloads:
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustupexport RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustupFedora’s add-ons are separate packages:
sudo dnf install rustfmt clippyCommon traps
Section titled “Common traps”| Symptom | Cause |
|---|---|
| crate downloads slow or failing | no mirror configured, or a git index instead of sparse+ |
cargo: command not found | only rust installed (rustc alone); add cargo |
| rustup toolchain not taking effect | /usr/bin/cargo wins; check which -a cargo |
rustfmt missing | it is a separate package on Fedora, not a rustup component |
| linking runs out of memory | use -j1 or add swap |
Related pages
Section titled “Related pages”- Domestic mirrors — crates and rustup mirrors
- Installing Go — the other compiled toolchain
- Containers and rootless — pinned versions and isolation
- Toolchain and multiple versions — the overall strategy
- Official: Rust