Skip to content
Search Fedora

    Browse this documentation

    Installing Rust on Fedora: 1.98 and a domestic crates mirror

    Terminal window
    sudo dnf install cargo rust
    rustc --version
    cargo --version
    rustc 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.

    The repository rustc/cargo route versus rustup

    Terminal window
    cargo new hello
    cd hello
    cargo run

    cargo new creates Cargo.toml and src/main.rs; cargo run compiles and executes.

    Terminal window
    cargo build --release
    ./target/release/hello

    cargo fetches from index.crates.io by default, which is slow here:

    Terminal window
    mkdir -p ~/.cargo
    cat > ~/.cargo/config.toml <<'EOF'
    [source.crates-io]
    replace-with = 'tuna'
    [source.tuna]
    registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"
    EOF

    The sparse+ prefix matters — it uses the HTTP index instead of cloning git, which is an order of magnitude faster.

    This is the part that needs saying clearly:

    You wantUse
    build existing projects, CIdnf install cargo rust, upgrades follow Fedora
    a pinned releaserustup
    nightly / beta toolchainsrustup (the repository carries stable only)
    cross compilation, rustup target addrustup
    full isolationthe 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:

    Terminal window
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    source ~/.cargo/env
    rustup toolchain install nightly
    rustup default nightly

    Domestic acceleration for rustup downloads:

    Terminal window
    export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
    export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup

    Fedora’s add-ons are separate packages:

    Terminal window
    sudo dnf install rustfmt clippy
    SymptomCause
    crate downloads slow or failingno mirror configured, or a git index instead of sparse+
    cargo: command not foundonly rust installed (rustc alone); add cargo
    rustup toolchain not taking effect/usr/bin/cargo wins; check which -a cargo
    rustfmt missingit is a separate package on Fedora, not a rustup component
    linking runs out of memoryuse -j1 or add swap