Skip to content

Request stdlib cache dir in gopackagesdriver#4391

Merged
fmeum merged 1 commit intobazel-contrib:masterfrom
monogon:cache-fix
Jul 2, 2025
Merged

Request stdlib cache dir in gopackagesdriver#4391
fmeum merged 1 commit intobazel-contrib:masterfrom
monogon:cache-fix

Conversation

@jscissr
Copy link
Copy Markdown
Contributor

@jscissr jscissr commented Jul 2, 2025

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

The stdlib_json_file contains paths of compiled cgo files, which are in the stdlib cache_dir. The gopackagesdriver reads those files, but this dependency was not explicitly declared previously.

Usually, it works despite the missing dependency. But when you have a Bazel cache configured, and then run bazel clean and run the gopackagesdriver again, Bazel will not restore the cache_dir from the Bazel cache. The gopackagesdriver then fails with an error like this:

error: unable to load JSON files: unable to resolve imports: open [...]/bin/external/rules_go+/stdlib_/gocache/a4/a4f91e8314b27a4bce0e8fbc01bb9736cb9ed10da747af722c5a4f2fcb1213a3-d: no such file or directory

This change adds a new output group containing the stdlib cache_dir, and requests this from the gopackagesdriver, fixing the problem.

The stdlib_json_file contains paths of compiled cgo files, which are in
the stdlib cache_dir. The gopackagesdriver reads those files, but this
dependency was not explicitly declared previously.

Usually, it works despite the missing dependency. But when you have a
Bazel cache configured, and then run `bazel clean` and run the
gopackagesdriver again, Bazel will not restore the cache_dir from the
Bazel cache. The gopackagesdriver then fails with an error like this:

error: unable to load JSON files: unable to resolve imports: open
[...]/bin/external/rules_go+/stdlib_/gocache/a4/a4f91e8314b27a4bce0e8fbc01bb9736cb9ed10da747af722c5a4f2fcb1213a3-d:
no such file or directory

This change adds a new output group containing the stdlib cache_dir,
and requests this from the gopackagesdriver, fixing the problem.
Copy link
Copy Markdown
Member

@fmeum fmeum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down?

@fmeum fmeum enabled auto-merge (squash) July 2, 2025 14:23
@fmeum fmeum merged commit 12d27d2 into bazel-contrib:master Jul 2, 2025
1 check passed
@jscissr jscissr deleted the cache-fix branch July 2, 2025 14:38
@blockjon-dd
Copy link
Copy Markdown

For what its worth, it appears that once we began using this version of rules_go, all of our builds started failing with this following sort of error:

...
fork/exec /home/builder/.cache/bazel/_bazel_builder/e77cf729f8701a609e6babb1491b4af8/external/rules_go++go_sdk+go_sdk_download/bin/go: no such file or directory

It seemed to taint each of our persistent CI agents where this new version was utilized. To remedy, we had to bounce our CI fleet bc the cache seems to have been corrupted in a way I dont understand yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants