-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: adding gopls as a tool dependency leads to build failures #73279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Release of |
Where did this command come from? (Is there some incorrect documentation recommending it?)
What command did you run? Unless you have git clone of x/tools, you cannot build versions of gopls that are not on a release branch. |
From I use this to pin the exact version of tools I'm using in our CI/CD pipelines, to ensure reproducible builds. Previously I was using a sub-module with a Dependency updates are coming from Renovate, which is trying to update |
I've also run into this issue (I used
Specifically wanted to add to this, I don't think there is any documentation necessarily recommending to use |
Me too. I used |
@matloob, is this an interaction between vendoring of x/tools in goroot and the new |
To reproduce: $ cd $(mktemp -d)
$ go mod init example
go: creating new go.mod: module example
$ go get -tool golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest
go: added golang.org/x/mod v0.23.0
go: added golang.org/x/sync v0.11.0
go: added golang.org/x/tools v0.30.1-0.20250221230316-5055f70f240c
go: added golang.org/x/tools/gopls v0.18.1
$ go get -tool golang.org/x/tools/cmd/stringer@latest
go: upgraded golang.org/x/mod v0.23.0 => v0.24.0
go: upgraded golang.org/x/sync v0.11.0 => v0.13.0
go: upgraded golang.org/x/tools v0.30.1-0.20250221230316-5055f70f240c => v0.32.0
$ go tool modernize
# golang.org/x/tools/gopls/internal/analysis/modernize
$HOME/go/pkg/mod/golang.org/x/tools/[email protected]/internal/analysis/modernize/bloop.go:167:29: c.Ancestors undefined (type cursor.Cursor has no field or method Ancestors)
$HOME/go/pkg/mod/golang.org/x/tools/[email protected]/internal/analysis/modernize/rangeint.go:156:15: cur.Edge undefined (type cursor.Cursor has no field or method Edge)
$HOME/go/pkg/mod/golang.org/x/tools/[email protected]/internal/analysis/modernize/rangeint.go:159:15: cur.Edge undefined (type cursor.Cursor has no field or method Edge)
$HOME/go/pkg/mod/golang.org/x/tools/[email protected]/internal/analysis/modernize/splitseq.go:55:30: curRange.Edge undefined (type cursor.Cursor has no field or method Edge)
$HOME/go/pkg/mod/golang.org/x/tools/[email protected]/internal/analysis/modernize/testingcontext.go:113:26: curFunc.Edge undefined (type cursor.Cursor has no field or method Edge)
$ cat go.mod
module example
go 1.24.1
tool (
golang.org/x/tools/cmd/stringer
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize
)
require (
golang.org/x/mod v0.24.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/tools v0.32.0 // indirect
golang.org/x/tools/gopls v0.18.1 // indirect
) Note: |
Hi @adonovan, I suspect the new I think the reason for the behavior in @corani's example in #73279 (comment) is briefly explained in the documentation:
It would probably be good to better document some of the alternatives to using |
Thanks @corani and @thepudds, that explains it. The issue here is that the modernize command, currently (but not fundamentally) part of the gopls module, is governed by the gopls release process, and you can't just upgrade the x/tools package to a later one, as happens when installing stringer, because the gopls release branch needs a particular version and x/tools does not present a stable internal API to gopls. In short, no-one should ever add gopls as a module dependency, and that means you cannot use @matloob mentioned that there was a discussion during the design of the |
Change https://go.dev/cl/665636 mentions this issue: |
The problem is that gopls needs exactly the right version of x/tools, as found on its release branch. The solution to an MVS constraint system which requires x/tools at higher versions will inevitably lead to build failures. (We should move modernize to x/tools.) Updates golang/go#73279 Change-Id: I6f43bb2e74b29384cedcb92b5d958cf695aa529d Reviewed-on: https://go-review.googlesource.com/c/tools/+/665636 Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Change https://go.dev/cl/665637 mentions this issue: |
(Belatedly addresses review comments on CL 665636.) Updates golang/go#73279 Change-Id: I03c2e5e2306f7c6de349e7d11ba87df6332622f5 Reviewed-on: https://go-review.googlesource.com/c/tools/+/665637 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
golang/go#73279 Signed-off-by: Andrew Haines <[email protected]>
golang/go#73279 Signed-off-by: Andrew Haines <[email protected]>
golang/go#73279 Signed-off-by: Andrew Haines <[email protected]>
gopls version
go env
What did you do?
go tool modernize --fix ./...
What did you see happen?
What did you expect to see?
no errors :)
Editor and settings
No response
Logs
No response
The text was updated successfully, but these errors were encountered: