bazel-contrib / bazel-gazelle

Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
Apache License 2.0
1.22k stars 381 forks source link

Cache is non-deterministic #1278

Open olebedev opened 2 years ago

olebedev commented 2 years ago

What version of gazelle are you using?

v0.25.0

What version of rules_go are you using?

v0.29.0

What version of Bazel are you using?

bazel 4.2.2- (@non-git)

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

macOs, x86_64

What did you do?

I am trying to build a Bazel Golang target in Nix, so I use nixpkgs#buildBazelPackage for that propose.

This Nix builder is separated into two steps:

  1. fetch everything external the project depends on, as a fixed output Nix derivation,
  2. build the artifacts without accessing the network.

What did you expect to see?

I expect the content of /external/bazel_gazelle_go_repository_cache/gocache/* be deterministic.

What did you see instead?

The issue I faced is that the first step always has a different SHA sum, i.e. the fetch step is not deterministic. I dived into a diff of two different artifacts of the same (first) step and found that the content of /external/bazel_gazelle_go_repository_cache/gocache/* is always different. Find the report files attached as diff-report.zip.

For example, the bazel_gazelle_go_repository_cache/gocache/00/003a22947d1e36c02d3d9cade996607c9cbcd222764a20a3699a0b8aef5fff51-a file has different content:

v1 007688a81bee9cf693e57dadb0079521c057cfccf88c215e7affeb16c11d19f0 88de97a1043a3a1c11819e4bbf7e1aed5685426bc56fb7ad10595944c3bbbe37                    9  1655435659820884000

and

v1 007688a81bee9cf693e57dadb0079521c057cfccf88c215e7affeb16c11d19f0 88de97a1043a3a1c11819e4bbf7e1aed5685426bc56fb7ad10595944c3bbbe37                    9  1655435353467998000
ee5cd7d5d commented 8 months ago

@olebedev I also have this problem with Bazel 6.2.0, the go_sdk 1.19.3 and io_bazel_rules_go 0.39.0 on Windows 10. Do you still have the issue, and did you figure out where the problem is/was?