Cargo fails to download dependencies when running in GitHub Actions

Viewed 1122

When cargo check runs in a GitHub Action, it downloads most of the dependencies but occasionally fails on one of them. It fails on different ones on each run (I tested it around 5 times).

Downloading dependencies works locally.

  Downloaded sys-info v0.5.10
  Downloaded strum_macros v0.19.4
  Downloaded proc-macro-error v1.0.4
  Downloaded pin-utils v0.1.0
  Downloaded v_escape v0.15.0
  Downloaded uuid v0.7.4
  Downloaded typeable v0.1.2
  Downloaded syn v1.0.73
  Downloaded strum v0.20.0
error: failed to download from `https://crates.io/api/v1/crates/rustc-demangle/0.1.20/download`
Error: failed to download from `https://crates.io/api/v1/crates/rustc-demangle/0.1.20/download`
Caused by:
  [55] Failed sending data to the peer (Connection died, tried 5 times before giving up)
Error: The process '/usr/share/rust/.cargo/bin/cargo' failed with exit code 101

What is causing this?

1 Answers

Seems like it’s a problem with the nightly toolchain.
Changing toochain: nightly to toolchain: nightly-2021-07-05 in the ci file solved it:

uses: actions-rs/toolchain@v1
with:
  profile: minimal
  toolchain: nightly-2021-07-05
  override: true
  components: rustfmt
Related