Skip to content

gopackagesdriver: disable path mapping for GoStdlibList action#4585

Merged
fmeum merged 1 commit into
bazel-contrib:masterfrom
juanzolotoochin:fix_gopackagesdriver_path_mapping_stdlib
Apr 7, 2026
Merged

gopackagesdriver: disable path mapping for GoStdlibList action#4585
fmeum merged 1 commit into
bazel-contrib:masterfrom
juanzolotoochin:fix_gopackagesdriver_path_mapping_stdlib

Conversation

@juanzolotoochin

@juanzolotoochin juanzolotoochin commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Since #4441, the GoStdlibList action uses SUPPORTS_PATH_MAPPING_REQUIREMENT and passes the cache directory via add_all (which enables path mapping). This causes the stdlib builder to write path-mapped directory names (e.g. bazel-out/cfg/) into stdlib.pkg.json. The gopackagesdriver then reads these paths at runtime to open source files, but the mapped directory doesn't exist on disk — the actual files are under the real config directory (e.g. bazel-out/k8-fastbuild/).

This breaks the gopackagesdriver for any Go target:

error: unable to resolve imports: open .../bazel-out/cfg/bin/external/io_bazel_rules_go/stdlib_/gocache/...: no such file or directory

Affected stdlib packages are those with CGO-compiled files (net, os/user, internal/runtime/cgobench, etc.) whose CompiledGoFiles reference gocache entries under the mapped path.

Fix: Unlike the stdlib build action (_build_stdlib), the GoStdlibList action produces stdlib.pkg.json which is consumed at runtime by the gopackagesdriver — not by Bazel. Path mapping is not appropriate here because the mapped paths are never resolved back to real paths before being read. Revert to using cache_dir.path (real filesystem path) and remove SUPPORTS_PATH_MAPPING_REQUIREMENT from this action only.

This PR is an alternative to #4584 which tried to resolve this at the gopackagesdriver but that solution was deemed brittle.

@fmeum fmeum enabled auto-merge (squash) April 7, 2026 20:13
@fmeum fmeum merged commit 4f7900f into bazel-contrib:master Apr 7, 2026
1 check passed
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.

2 participants