Go version
go1.25-devel_cfb4e9bc4a
Output of go env
in your module/workspace:
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE='on'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN='/Users/rhang/gocode/bin'
GOCACHE='/Users/rhang/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/rhang/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/f6/p6sx9gt977l5n0hngdbjpnch0000gn/T/go-build3572606388=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/rhang/gocode/src/github.com/golang/go/src/go.mod'
GOMODCACHE='/Users/rhang/gocode/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/rhang/gocode'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/rhang/gocode/src/github.com/golang/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/rhang/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/rhang/gocode/src/github.com/golang/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25-devel_cfb4e9bc4a Tue Jun 3 13:34:49 2025 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
While testing upcoming go1.25 changes on our internal monorepo, we noticed this build failure for all go Bazel targets.
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
2025-06-09 00:44:46 PDT
compilepkg: error running subcommand external/go_sdk/pkg/tool/linux_amd64/pack: fork/exec external/go_sdk/pkg/tool/linux_amd64/pack: no such file or directory
2025-06-09 00:44:46 PDT
ERROR: /home/testuser/.cache/bazel-single-base/external/io_nhooyr_websocket/BUILD.bazel:3:11: GoCompilePkg external/io_nhooyr_websocket/websocket.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target @@io_nhooyr_websocket//:websocket) bazel-out/k8-opt-exec-ST-a828a81199fe/bin/external/go_sdk/builder_reset/builder compilepkg -sdk external/go_sdk -goroot bazel-out/k8-fastbuild/bin/external/io_bazel_rules_go/stdlib_ -installsuffix ... (remaining 63 arguments skipped)
What did you see happen?
While building go after https://github.com/golang/go/commit/cfb4e9bc4ae957dba63cb2ee5e020fcd25d553fd the pack command is missing.
../bin/go tool
asm
cgo
compile
cover
link
preprofile
vet
What did you expect to see?
Since rules_go for Bazel relies on the pack tool https://github.com/bazel-contrib/rules_go/blob/master/go/tools/builders/compilepkg.go#L504 to emulate the go toolchain compiler logic https://github.com/golang/go/blob/master/src/cmd/go/internal/work/exec.go#L965 would it be possible to keep the pack command exposed for lower-level callers of the go toolchain?
Comment From: gabyhelp
Related Issues
- Cannot use make.bash to build go pkg #59515 (closed)
- go1.13b1 tool compile -p breaks main packages #33055 (closed)
- Can not build the image locally #45251 (closed)
- cmd/compile: internal compiler error: missing pkg #56186 (closed)
- x/tools/go/packages: loading should report error when use custom GOROOT #69606 (closed)
- build: the build of go bootstrap in case of compilation errors does not stop cleanly #45410 (closed)
- cmd/go: output of go build -x has invalid go pack command line #7262 (closed)
- cmd/dist: make.bash --no-clean fails when compilation target doesn't support regabi #47204 (closed)
- cmd/go: panic: LoadImport called with empty package path [recovered] when building source #67984 (closed)
- cmd/go: specifying `-n` causes error with cgo #14944 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: dmitshur
Thanks for the report. The corresponding release note for this is https://tip.golang.org/doc/go1.25#go-command (second paragraph, "The Go distribution will include fewer prebuilt tool binaries. …").
If rules_go were updated to use go tool pack
to invoke the pack
command, would that resolve the issue for you?
CC @golang/command-line.
Comment From: r-hang
Yes, I think that should work.
I can confirm that this patch to rules_go resolves the issue
diff --git a/go/private/actions/compilepkg.bzl b/go/private/actions/compilepkg.bzl
index 3b7f27ae..6b578fa7 100644
--- a/go/private/actions/compilepkg.bzl
+++ b/go/private/actions/compilepkg.bzl
@@ -202,6 +202,7 @@ def emit_compilepkg(
inputs_direct.append(go.mode.pgoprofile)
go.actions.run(
+ tools = [go.toolchain.sdk.go],
inputs = depset(inputs_direct, transitive = inputs_transitive),
outputs = outputs,
mnemonic = "GoCompilePkgExternal" if is_external_pkg else "GoCompilePkg",
diff --git a/go/tools/builders/compilepkg.go b/go/tools/builders/compilepkg.go
index d9e6454f..f7250778 100644
--- a/go/tools/builders/compilepkg.go
+++ b/go/tools/builders/compilepkg.go
@@ -501,7 +501,7 @@ func compileGo(goenv *env, srcs []string, packagePath, importcfgPath, embedcfgPa
func appendToArchive(goenv *env, outPath string, objFiles []string) error {
// Use abs to work around long path issues on Windows.
- args := goenv.goTool("pack", "r", abs(outPath))
+ args := goenv.goCmd("tool", "pack", "r", abs(outPath))
args = append(args, objFiles...)
return goenv.runCommand(args)
}
I apologize for the confusion. I made a mistake before filing this issue, during my investigation, when I got to a state where my locally built go tool pack
complained that the pack
command was also not recognized. This is no longer the case.
Thanks, @dmitshur!