Description
Go version
1.23.5
Output of go env
in your module/workspace:
Zemnmez ➜ /workspaces/monorepo (6999e71122) $ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/codespace/.cache/go-build'
GOENV='/home/codespace/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/codespace/.cache/bazel/_bazel_codespace/f4ac7acc8046f57d430e720e89de5487/external/rules_go++go_sdk+monorepo__download_0'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/codespace/.cache/bazel/_bazel_codespace/f4ac7acc8046f57d430e720e89de5487/external/rules_go++go_sdk+monorepo__download_0/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.5'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/codespace/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/workspaces/monorepo/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3892102254=/tmp/go-build -gno-record-gcc-switches'
@Zemnmez ➜ /workspaces/monorepo (6999e71122) $
What did you do?
I have gopls in my tools.go
so it is controlled by go.mod: https://github.com/zemn-me/monorepo/blob/91a487a370933573cf8ba6b46e3563a39c617ecb/sh/tools.go#L12
[email protected] (@latest) depends on a weird dev version of x/tools (v0.27.1-0.20241219162658-575221bfbda3): https://cs.opensource.google/go/x/tools/+/refs/tags/gopls/v0.17.1:gopls/go.mod;l=15
When I run go mod tidy
, it reverts the version to x/[email protected] (@latest), which I think is correct as per semver. This breaks the build as gopls
is incompatible with that version.
What did you see happen?
Without replace directive (zemn-me/monorepo@91a487a):
@Zemnmez ➜ /workspaces/monorepo (6999e71122) $ go mod tidy
@Zemnmez ➜ /workspaces/monorepo (6999e71122) $ bazel run //sh/bin:gopls
WARNING: Option 'experimental_remote_cache_compression' is deprecated: Use --remote_cache_compression instead
INFO: Invocation ID: 883ed3fd-68a7-47fd-bb41-e09d06494785
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/883ed3fd-68a7-47fd-bb41-e09d06494785
WARNING: Option 'experimental_remote_cache_compression' is deprecated: Use --remote_cache_compression instead
INFO: Analyzed target //sh/bin:gopls (100 packages loaded, 622 targets configured).
ERROR: /home/codespace/.cache/bazel/_bazel_codespace/f4ac7acc8046f57d430e720e89de5487/external/gazelle++go_deps+org_golang_x_tools_gopls/internal/analysis/fillreturns/BUILD.bazel:3:11: GoCompilePkg external/gazelle++go_deps+org_golang_x_tools_gopls/internal/analysis/fillreturns/fillreturns.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target @@gazelle++go_deps+org_golang_x_tools_gopls//internal/analysis/fillreturns:fillreturns) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_go++go_sdk+monorepo__download_0/builder_reset/builder compilepkg -sdk external/rules_go++go_sdk+monorepo__download_0 -goroot ... (remaining 37 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/gazelle++go_deps+org_golang_x_tools_gopls/internal/analysis/fillreturns/fillreturns.go:187:23: assignment mismatch: 1 variable but typesinternal.ZeroExpr returns 2 values
external/gazelle++go_deps+org_golang_x_tools_gopls/internal/analysis/fillreturns/fillreturns.go:187:62: too many arguments in call to typesinternal.ZeroExpr
have (*ast.File, *types.Package, types.Type)
want (types.Type, types.Qualifier)
compilepkg: error running subcommand external/rules_go++go_sdk+monorepo__download_0/pkg/tool/linux_amd64/compile: exit status 2
Target @@gazelle++go_deps+org_golang_x_tools_gopls//:gopls failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.387s, Critical Path: 0.31s
INFO: 49 processes: 35 action cache hit, 40 disk cache hit, 7 internal, 2 linux-sandbox.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
FAILED:
Waiting for build events upload: Build Event Service 23s
What did you expect to see?
I fixed this issue with a replace directive, added to go.mod (zemn-me/monorepo@6999e71):
replace golang.org/x/tools => golang.org/x/tools v0.27.1-0.20241219162658-575221bfbda3
It fixes the issue, but it seems like it should not be needed:
@Zemnmez ➜ /workspaces/monorepo (6999e71122) $ go mod tidy
b@Zemnmez ➜ /workspaces/monorepo (6999e71122) $ bazel run //sh/bin:gopls
WARNING: Option 'experimental_remote_cache_compression' is deprecated: Use --remote_cache_compression instead
INFO: Invocation ID: 5a745502-d7a1-4d3f-aeee-82272d42ce48
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/5a745502-d7a1-4d3f-aeee-82272d42ce48
WARNING: Option 'experimental_remote_cache_compression' is deprecated: Use --remote_cache_compression instead
INFO: Analyzed target //sh/bin:gopls (100 packages loaded, 620 targets configured).
INFO: Found 1 target...
Target @@gazelle++go_deps+org_golang_x_tools_gopls//:gopls up-to-date:
dist/bin/external/gazelle++go_deps+org_golang_x_tools_gopls/gopls_/gopls
INFO: Elapsed time: 1.092s, Critical Path: 0.04s
INFO: 49 processes: 288 action cache hit, 48 disk cache hit, 1 internal.
INFO: Build completed successfully, 49 total actions
INFO: Running command line: dist/bin/external/gazelle++go_deps+org_golang_x_tools_gopls/gopls_/gopls
INFO: