nix-community / nixpkgs-fmt

Nix code formatter for nixpkgs [maintainer=@zimbatm]
https://nix-community.github.io/nixpkgs-fmt/
Apache License 2.0
581 stars 34 forks source link

Pre-Commit fails sporadically with `failed to compile nixpkgs-fmt` #312

Open hofbi opened 1 year ago

hofbi commented 1 year ago

Describe the bug

I am using nixpkgs-fmt via pre-commit and it fails from time to time in the CI with

[INFO] Installing environment for https://github.com/nix-community/nixpkgs-fmt.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/runner/.cargo/bin/cargo', 'install', '--bins', '--root', '/home/runner/.cache/pre-commit/repoawuydlo9/rustenv-system', '--path', '.')
return code: 101
stdout: (none)
stderr:
      Installing nixpkgs-fmt v1.3.0 (/home/runner/.cache/pre-commit/repoawuydlo9)
        Updating crates.io index
    warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
    warning: spurious network error (2 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
    warning: spurious network error (1 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
    error: failed to compile `nixpkgs-fmt v1.3.0 (/home/runner/.cache/pre-commit/repoawuydlo9)`, intermediate artifacts can be found at `/home/runner/.cache/pre-commit/repoawuydlo9/target`

    Caused by:
      failed to get `syn` as a dependency of package `serde_derive v1.0.186`
          ... which satisfies dependency `serde_derive = "=1.0.186"` of package `serde v1.0.186`
          ... which satisfies dependency `serde = "^1.0.136"` of package `smol_str v0.1.24`
          ... which satisfies dependency `smol_str = "^0.1.17"` of package `nixpkgs-fmt v1.3.0 (/home/runner/.cache/pre-commit/repoawuydlo9)`

    Caused by:
      failed to query replaced source registry `crates-io`

    Caused by:
      download of 3/s/syn failed

    Caused by:
      failed to download from `https://index.crates.io/3/s/syn`

    Caused by:
      [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
Check the log at /home/runner/.cache/pre-commit/pre-commit.log

To Reproduce

My pre-commit config contains

  - repo: https://github.com/nix-community/nixpkgs-fmt
    rev: 6d2dee8954cc4e790dede82ddff2aeac4a32da46
    hooks:
      - id: nixpkgs-fmt

Since it is a flaky issue it is not reproducible, but it happens as part of the pre-commit github action

Expected behavior

Do not fail wih the error mentioned above

System information

Additional context

I found https://github.com/rust-lang/cargo/issues/12525, which was resolved today. Maybe this is related.