Skip to content
Latchkey

Rustup "could not download file" - Toolchain Install Fails in CI

rustup could not download a toolchain or component from static.rust-lang.org. This is almost always a transient network failure during the fetch, not a problem with your project, and usually succeeds on retry.

What this error means

A rustup toolchain install / rustup component add step fails with could not download file from <url> to <path> and a transfer/timeout error. Re-running the job typically works unchanged -- the hallmark of a transient issue.

rustup
info: downloading component 'rust-std'
error: could not download file from
'https://static.rust-lang.org/dist/.../rust-std-....tar.xz' to '...'
Caused by: error during download ... timed out

Common causes

Transient network failure during the fetch

A brief connectivity blip or a slow response from static.rust-lang.org (or its CDN) drops the download mid-transfer. Nothing is wrong with your setup.

Cold runner re-downloading the toolchain

A fresh runner with no cached ~/.rustup must download the full toolchain and components every run -- more exposure to a flaky link.

How to fix it

Retry the install

Wrap the rustup call in a small retry loop so a single transient failure does not fail the job.

Terminal
for i in 1 2 3; do
  rustup toolchain install stable && break
  sleep 5
done

Cache the rustup directory

Caching ~/.rustup between runs means the toolchain is already local, so a flaky network matters far less.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.rustup
    key: rustup-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}

How to prevent it

  • Cache ~/.rustup so toolchains and components persist across runs.
  • Retry rustup installs to absorb transient download failures.
  • On Latchkey managed runners, transient toolchain-download failures are auto-retried and the toolchain is cached, so cold installs do not flake out a build.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →