actions-rust-lang/setup-rust-toolchain

Running rust-toolchain twice in same workflow can result in unstable errors

neoeinstein opened this issue · 4 comments

Example workflow where we use the nightly for formatting, but stable for linting with Clippy:

    steps:
      - uses: actions/checkout@v3
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: rustfmt
      - run: cargo +nightly fmt --all -- --check
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo clippy --all-targets --all-features --locked -- -D warnings

This results in the following error when trying to run the clippy command:

  env:
    CARGO_INCREMENTAL: 0
    CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  
error: failed to get `axum` as a dependency of package `CRATE v0.1.0 (/runner/_work/PATH)`

Caused by:
  failed to load source for dependency `axum`

Caused by:
  Unable to update registry `crates-io`

Caused by:
  usage of sparse registries requires `-Z sparse-registry`
Error: Process completed with exit code 101.

Meant to post this over at dtolnay's repository. It's now there as dtolnay/rust-toolchain#73.

Since I based this on dtolnay's action I was curious about the issue. But I cannot reproduce it. Neither with this action nor with your code snippet. I only get this when running clippy. This seem caused by the trailing -- -D.

error: multiple input filenames provided (first two filenames are `src/main.rs` and `feature="cargo-clippy"`)

Do you have a repository and a link to an actions log where this error occurs?

See dtolnay/rust-toolchain#74. This has now been fixed in that repository. I fixed the above. it should have been -D warnings, but could have been left off for this.

I published a fix for this problem. It ended up quite different from dtolnay/rust-toolchain#74 because that fix is incomplete.