Go version
go version go1.24.4 darwin/arm64
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=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/officialnsa/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/officialnsa/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/kl/kqwhw69x11z0bj42fhljq57c0000gn/T/go-build1909660288=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/officialnsa/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/officialnsa/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/officialnsa/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.4'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
Attempted to install gopls
using the recommended installation method:
$ go install golang.org/x/tools/gopls@latest
I should note, this was after attempting to install using mason.nvim
. I also uninstalled go
via brew
and installed using the package installer, but still encountered the issue.
What did you see happen?
go: golang.org/x/tools/gopls@latest: module golang.org/x/tools/gopls@latest found (v0.18.1), but does not contain package golang.org/x/tools/gopls
What did you expect to see?
Expected to see a successful installation, but encountered this error after every attempt.
I noticed this issue was reported in #59281, but never resolved. I've also seen multiple reports by mason.nvim
users that they've encountered this issue—some people had this fixed by unsetting GOOS
and GOARCH
, but that didn't resolve the issue for me.
Comment From: seankhliao
What's in /Users/officialnsa/go/pkg/mod/golang.org/x/tools/gopls@v0.18.1/
?
Comment From: gabyhelp
Related Issues
- x/tools/gopls: cannot install gopls v0.6.8 #45099 (closed)
- cmd/go: install: module found, but does not contain package on 1.20.2, works fine on 1.19.7 #59281 (closed)
- Can not install go module ! what's problem ? #44856 (closed)
- cmd/go: install golang.org/x/tools/gopls@latest failed #65431 (closed)
- x/tools/gopls: latest gopls install fails on MacOS #62162 (closed)
- x/tools/gopls: package (still) not found when "linksInHover": "gopls" #68223 (closed)
- x/tools/gopls: CLI command not found: gopls #35924 (closed)
- x/tools/gopls: cannot find package error while installing #36442 (closed)
- can't install golang.org/x/tools/gopls@latest #34076 (closed)
- x/tools/gopls: gopls and other tool installs fail on 2021 M1 Max Mac #66012 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: ancientjpeg
What's in
/Users/officialnsa/go/pkg/mod/golang.org/x/tools/gopls@v0.18.1/
?
Here's the contents of that directory:
$ ls -l /Users/officialnsa/go/pkg/mod/golang.org/x/tools/gopls@v0.18.1/
total 48
dr-xr-xr-x@ 26 officialnsa staff 832 Jun 11 12:09 doc
-r--r--r--@ 1 officialnsa staff 922 Jun 11 12:09 go.mod
-r--r--r--@ 1 officialnsa staff 3966 Jun 11 12:09 go.sum
dr-xr-xr-x@ 3 officialnsa staff 96 Jun 11 12:09 integration
dr-xr-xr-x@ 28 officialnsa staff 896 Jun 11 12:09 internal
-r--r--r--@ 1 officialnsa staff 1453 Jun 11 12:09 LICENSE
-r--r--r--@ 1 officialnsa staff 1943 Jun 11 12:09 main.go
-r--r--r--@ 1 officialnsa staff 6953 Jun 11 12:09 README.md
Comment From: seankhliao
What happens if you run go build
in that directory?
What's the output of go env -changed
Comment From: ancientjpeg
Got this output after go build
, looks like this could be the issue:
open /Users/officialnsa/Library/Caches/go-build/c5/c5f4284ee34bd71d68a156f0b51808a1a4e477c5d72f2133292284071c84cf18-d: permission denied
I removed/Users/officialnsa/Library/Caches/go-build/
hoping it'd just be some messed up permissions in a cache directory, but attempting to run go build
again hit another similar error:
golang.org/x/tools/gopls: go build golang.org/x/tools/gopls: copying /var/folders/kl/kqwhw69x11z0bj42fhljq57c0000gn/T/go-build3851254186/b001/exe/a.out: open gopls: permission denied
Comment From: seankhliao
the second failure is expected because the module cache is read only does go install still fail?
Comment From: ancientjpeg
Nope, it works now! Thanks so much for your assistance. I'll close out this issue.