gopls: can't install golang.org/x/tool/gopls@latest

Created on 27 Nov 2019  ·  7Comments  ·  Source: golang/go

Please answer these questions before submitting your issue. Thanks!

What did you do?

$ GO111MODULE=on go get golang.org/x/tools/gopls@latest

What did you expect to see?

gopls is installed.

What did you see instead?

I got the error output

go: finding golang.org/x/tools/gopls v0.2.1
go: downloading golang.org/x/tools/gopls v0.2.1
go: extracting golang.org/x/tools/gopls v0.2.1
go: downloading golang.org/x/tools v0.0.0-20191126225216-7360bd5c0f4e
go: extracting golang.org/x/tools v0.0.0-20191126225216-7360bd5c0f4e
go: downloading honnef.co/go/tools v0.0.1-2019.2.3
go: downloading github.com/sergi/go-diff v1.0.0
go: downloading golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
go: downloading golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
go: extracting github.com/sergi/go-diff v1.0.0
go: extracting golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
go: extracting golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
go: extracting honnef.co/go/tools v0.0.1-2019.2.3
go: downloading github.com/BurntSushi/toml v0.3.1
go: extracting github.com/BurntSushi/toml v0.3.1
go: finding golang.org/x/tools v0.0.0-20191126225216-7360bd5c0f4e
go: finding github.com/sergi/go-diff v1.0.0
go: finding honnef.co/go/tools v0.0.1-2019.2.3
go: finding golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
go: finding github.com/BurntSushi/toml v0.3.1
go: finding golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
# golang.org/x/tools/gopls/internal/hooks
../../../../go/pkg/mod/golang.org/x/tools/[email protected]/internal/hooks/analysis.go:17:30: first argument to append must be slice; have map[string]*analysis.Analyzer
../../../../go/pkg/mod/golang.org/x/tools/[email protected]/internal/hooks/analysis.go:20:30: first argument to append must be slice; have map[string]*analysis.Analyzer
../../../../go/pkg/mod/golang.org/x/tools/[email protected]/internal/hooks/analysis.go:23:30: first argument to append must be slice; have map[string]*analysis.Analyzer

Build info

golang.org/x/tools/gopls 0.2.0
    golang.org/x/tools/[email protected] h1:ddCHfScTYOG6auAcEKXCFN5iSeKSAnYcPv+7zVJBd+U=
    github.com/BurntSushi/[email protected] h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/[email protected] h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
    golang.org/x/[email protected] h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/[email protected] h1:FNzasIzfY1IIdyTs/+o3Qv1b7YdffPbBXyjZ5VJJdIA=
    golang.org/x/[email protected] h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
    honnef.co/go/[email protected] h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=

Go info

go version go1.13.4 darwin/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kyoh86/Library/Caches/go-build"
GOENV="/Users/kyoh86/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/kyoh86/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/kyoh86/Projects/github.com/wcl48/ai-analyst-back/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y8/4b8kv6r967jdyxxf8q797njr0000gn/T/go-build328153880=/tmp/go-build -gno-record-gcc-switches -fno-common"
gopls

Most helpful comment

If you aren't using -u, don't have a go.mod and are having the issue above, try running rm -r $GOPATH/pkg/mod/golang.org/x/tools/gopls@VERSIONHERE/ in case you have a bad cache that is messing up the command. It worked for me at least.

All 7 comments

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

Sorry it's caused by my go.mod.

Not sure, whether I should open a new ticket here, but I could reproduce it without any go.mod by directly running

$ (GO111MODULE=on  go get -u golang.org/x/tools/gopls@latest)
go: finding golang.org/x/tools latest
go: finding golang.org/x/tools/gopls v0.2.1
go: downloading golang.org/x/tools/gopls v0.2.1
go: downloading golang.org/x/tools v0.0.0-20191209225234-22774f7dae43
go: extracting golang.org/x/tools/gopls v0.2.1
go: extracting golang.org/x/tools v0.0.0-20191209225234-22774f7dae43
go: downloading golang.org/x/tools v0.0.0-20191108194844-46f05828f2fe
go: extracting golang.org/x/tools v0.0.0-20191108194844-46f05828f2fe
go: downloading honnef.co/go/tools v0.0.1-2019.2.3
go: downloading golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: downloading golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
go: downloading github.com/sergi/go-diff v1.0.0
go: extracting golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: extracting golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
go: extracting github.com/sergi/go-diff v1.0.0
go: extracting honnef.co/go/tools v0.0.1-2019.2.3
go: downloading github.com/BurntSushi/toml v0.3.1
go: extracting github.com/BurntSushi/toml v0.3.1
go: finding golang.org/x/sync latest
go: finding github.com/BurntSushi/toml v0.3.1
go: finding honnef.co/go/tools v0.0.1-2019.2.3
go: finding github.com/sergi/go-diff v1.0.0
go: finding golang.org/x/xerrors latest
go: downloading golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
go: downloading golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
go: extracting golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
go: extracting golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
# golang.org/x/tools/gopls/internal/hooks
go/pkg/mod/golang.org/x/tools/[email protected]/internal/hooks/analysis.go:17:30: first argument to append must be slice; have map[string]*analysis.Analyzer
go/pkg/mod/golang.org/x/tools/[email protected]/internal/hooks/analysis.go:20:30: first argument to append must be slice; have map[string]*analysis.Analyzer
go/pkg/mod/golang.org/x/tools/[email protected]/internal/hooks/analysis.go:23:30: first argument to append must be slice; have map[string]*analysis.Analyzer

Go version: go version go1.13.5 linux/amd64
Go env output:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ioeser/.cache/go-build"
GOENV="/home/ioeser/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ioeser/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/snap/go/4901"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/4901/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/user/1000/go-build565083837=/tmp/go-build -gno-record-gcc-switches"

-u should not be used in conjunction with the @latest tag, as it will give you incorrect versions of the dependencies.

Sorry it's caused by my go.mod.

How to fix it? Thanks!

@shiqinfeng1: Make sure not to run the go command in a directory with a go.mod file, as its dependencies may affect the installation of gopls. I would run the command from a temporary directory.

If you aren't using -u, don't have a go.mod and are having the issue above, try running rm -r $GOPATH/pkg/mod/golang.org/x/tools/gopls@VERSIONHERE/ in case you have a bad cache that is messing up the command. It worked for me at least.

Was this page helpful?
0 / 5 - 0 ratings