Skip to content

Conversation

@koct9i
Copy link

@koct9i koct9i commented Nov 26, 2025

GO111MODULE=auto disables modules when go tool sees only go.work file.

$ go version
go version go1.23.1 linux/amd64
$ echo 'go 1.24' > go.work
$ go version
go version go1.24.0 linux/amd64
$ GO111MODULE=auto go version
go version go1.23.1 linux/amd64

When go in $PATH is too old this breaks gopls for repositories like this:
https://github.com/containers/container-libs/

GO111MODULE=auto disables modules when go tool sees only go.work file.

$ go version
go version go1.23.1 linux/amd64
$ echo 'go 1.24' > go.work
$ go version
go version go1.24.0 linux/amd64
$ GO111MODULE=auto go version
go version go1.23.1 linux/amd64

When go in $PATH is too old this breaks gopls for repositories like this:
https://github.com/containers/container-libs/

Signed-off-by: Konstantin Khlebnikov <[email protected]>
@koct9i koct9i changed the title Set GO111MODULE=on for go.work view gopls/internal/cache: set GO111MODULE=on for go.work view Nov 26, 2025
@koct9i koct9i marked this pull request as ready for review November 26, 2025 11:13
@koct9i
Copy link
Author

koct9i commented Nov 26, 2025

Original issues looks like this

~/src/containers/container-libs$ gopls -vv check pkg/lockfile/lockfile.go 
2025/11/26 12:16:14 Info:2025/11/26 12:16:14 Created View (#1)
	directory=/home/khlebnikov/src/containers/container-libs
	view_type="GoWork"
	root_dir="file:///home/khlebnikov/src/containers/container-libs"
	go_version="go version go1.24.2 linux/amd64"
	build_flags=[]
	env={GOOS:linux GOARCH:amd64 GOCACHE:/home/khlebnikov/.cache/go-build GOMODCACHE:/home/khlebnikov/go/pkg/mod GOPATH:/home/khlebnikov/go GOPRIVATE: GOFLAGS: GO111MODULE: GOTOOLCHAIN:auto GOROOT:/home/khlebnikov/go/pkg/mod/golang.org/[email protected] GoVersion:23 GoVersionOutput:go version go1.24.2 linux/amd64
 ExplicitGOWORK: EffectiveGOPACKAGESDRIVER:}
	env_overlay=[]
2025/11/26 12:16:14 Info:2025/11/26 12:16:14 starting GOROOT= GOPATH= GO111MODULE=auto GOPROXY= PWD=/home/khlebnikov/src/containers/container-libs go list -f "{{context.GOARCH}} {{context.Compiler}}" -- unsafe
2025/11/26 12:16:14 Info:2025/11/26 12:16:14 starting GOROOT= GOPATH= GO111MODULE=off GOPROXY= PWD=/home/khlebnikov/src/containers/container-libs go list -e -f {{context.ReleaseTags}} -- unsafe
2025/11/26 12:16:14 Info:2025/11/26 12:16:14 6.292977ms for GOROOT= GOPATH= GO111MODULE=auto GOPROXY= PWD=/home/khlebnikov/src/containers/container-libs go list -f "{{context.GOARCH}} {{context.Compiler}}" -- unsafe
2025/11/26 12:16:14 Info:2025/11/26 12:16:14 6.58512ms for GOROOT= GOPATH= GO111MODULE=off GOPROXY= PWD=/home/khlebnikov/src/containers/container-libs go list -e -f {{context.ReleaseTags}} -- unsafe
2025/11/26 12:16:14 Info:2025/11/26 12:16:14 starting GOROOT= GOPATH= GO111MODULE=auto GOPROXY= PWD=/home/khlebnikov/src/containers/container-libs go list -e -json=Name,ImportPath,Error,Dir,GoFiles,IgnoredGoFiles,IgnoredOtherFiles,CFiles,CgoFiles,CXXFiles,MFiles,HFiles,FFiles,SFiles,SwigFiles,SwigCXXFiles,SysoFiles,TestGoFiles,XTestGoFiles,CompiledGoFiles,Export,DepOnly,Imports,ImportMap,TestImports,XTestImports,ForTest,DepsErrors,Module,EmbedFiles -compiled=true -test=true -export=false -deps=true -find=false -pgo=off -- /home/khlebnikov/src/containers/container-libs/common/... /home/khlebnikov/src/containers/container-libs/image/... /home/khlebnikov/src/containers/container-libs/storage/... builtin
2025/11/26 12:16:14 Info:2025/11/26 12:16:14 6.392822ms for GOROOT= GOPATH= GO111MODULE=auto GOPROXY= PWD=/home/khlebnikov/src/containers/container-libs go list -e -json=Name,ImportPath,Error,Dir,GoFiles,IgnoredGoFiles,IgnoredOtherFiles,CFiles,CgoFiles,CXXFiles,MFiles,HFiles,FFiles,SFiles,SwigFiles,SwigCXXFiles,SysoFiles,TestGoFiles,XTestGoFiles,CompiledGoFiles,Export,DepOnly,Imports,ImportMap,TestImports,XTestImports,ForTest,DepsErrors,Module,EmbedFiles -compiled=true -test=true -export=false -deps=true -find=false -pgo=off -- /home/khlebnikov/src/containers/container-libs/common/... /home/khlebnikov/src/containers/container-libs/image/... /home/khlebnikov/src/containers/container-libs/storage/... builtin
2025/11/26 12:16:14 Error:2025/11/26 12:16:14 go/packages.Load #1: err: exit status 1: stderr: go: go.work requires go >= 1.24.2 (running go 1.23.1)

	view_id="1"
	snapshot=0
	directory=/home/khlebnikov/src/containers/container-libs
	query=[/home/khlebnikov/src/containers/container-libs/common/... /home/khlebnikov/src/containers/container-libs/image/... /home/khlebnikov/src/containers/container-libs/storage/... builtin]
	packages=0
	duration=13.869724ms
2025/11/26 12:16:14 Error:2025/11/26 12:16:14 initial workspace load failed: packages.Load error: err: exit status 1: stderr: go: go.work requires go >= 1.24.2 (running go 1.23.1)

gopls: getFile: file:///home/khlebnikov/src/containers/container-libs/pkg/lockfile/lockfile.go: open /home/khlebnikov/src/containers/container-libs/pkg/lockfile/lockfile.go: no such file or directory

@gopherbot
Copy link
Contributor

This PR (HEAD: 30741a5) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/724262.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/724262.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.


Please don’t reply on this GitHub thread. Visit golang.org/cl/724262.
After addressing review feedback, remember to publish your drafts!

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