Skip to content
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

x/tools/gopls: gopls returns "getting file for Highlight: no PackageHandles" errors #39624

Closed
zhuzeng opened this issue Jun 16, 2020 · 4 comments
Closed
Labels
Milestone

Comments

@zhuzeng
Copy link

@zhuzeng zhuzeng commented Jun 16, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.4 linux/amd64

Does this issue reproduce with the latest release?

Yes. VS Code version:

Version: 1.46.0
Commit: a5d1cc28bb5da32ec67e86cc50f84c67cc690321
Date: 2020-06-10T08:59:06.977Z (6 days ago)
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 18.7.0

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/xxx"
GOENV="xxx"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/local/../zhuzenglu/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/google-golang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/path/to/my/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=/tmp/go-build445698442=/tmp/go-build -gno-record-gcc-switches"

What did you do?

The VS Studio Code Golang language server stops working (all of a sudden). I tried t0 reinstall the vs code app, uninstall the golang extension and install the latest multiple times, without any luck.

What did you expect to see?

It works just like before, can jump to code definitions.

What did you see instead?

This only stops working for my Linux machine, my Mac VS Code works just fine with the latest vs code app and same version of the latest golang extension.

I turned on the debugging of the golang language server and below are the errors I kept seeing (with some detailed go file path replaced with faked ones):

[Trace - 23:25:28.720 PM] Sending request 'textDocument/hover - (9)'.
Params: {"textDocument":{"uri":"file:///usr/local/path/to/my/go/code/example.go"},"position":{"line":32,"character":32}}

[Trace - 23:25:28.721 PM] Sending notification '$/cancelRequest'.
Params: {"id":9}

[Error - Received] 23:25:28.722 PM #9 JSON RPC cancelled

[Trace - 23:25:29.114 PM] Sending request 'textDocument/definition - (10)'.
Params: {"textDocument":{"uri":"file:///usr/local/path/to/my/go/code/example.go"},"position":{"line":32,"character":42}}

[Trace - 23:25:29.167 PM] Sending request 'textDocument/hover - (11)'.
Params: {"textDocument":{"uri":"file:///usr/local/path/to/my/go/code/example.go"},"position":{"line":32,"character":42}}

[Error - Received] 23:25:29.193 PM #10 getting file for Identifier: no PackageHandles

[Error - 11:25:29 PM] Request textDocument/definition failed.
Message: getting file for Identifier: no PackageHandles
Code: 0
[Trace - 23:25:29.194 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/06/16 23:25:29 go/packages.Load\n\tsnapshot=1\n\tdirectory=/usr/local/path/to/my/go/code/example.go\n\tquery=[file=/usr/local/path/to/my/go/code/example.go]\n\tpackages=0\n"}

[Info - 11:25:29 PM] 2020/06/16 23:25:29 go/packages.Load
snapshot=1
directory=/usr/local/path/to/my/go/code
query=[file=/usr/local/path/to/my/go/code/example.go]
packages=0

[Trace - 23:25:29.269 PM] Received response 'textDocument/hover - (11)' in 102ms.
Result: null

[Trace - 23:25:29.269 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/06/16 23:25:29 go/packages.Load\n\tsnapshot=1\n\tdirectory=/usr/local/path/to/my/go/code\n\tquery=[file=/usr/local/path/to/my/go/code/example.go]\n\tpackages=0\n"}

[Info - 11:25:29 PM] 2020/06/16 23:25:29 go/packages.Load
snapshot=1
directory=/usr/local/path/to/my/go/code
query=[file=/usr/local/path/to/my/go/code/example.go]
packages=0

[Trace - 23:25:29.350 PM] Sending request 'textDocument/codeAction - (12)'.
Params: {"textDocument":{"uri":"file://usr/local/path/to/my/go/code/example.go"},"range":{"start":{"line":32,"character":0},"end":{"line":32,"character":76}},"context":{"diagnostics":[{"range":{"start":{"line":32,"character":0},"end":{"line":32,"character":76}},"message":"exported method CloudResourceReconciler.SetupWithManager should have comment or be unexported","severity":2,"source":"go-lint"}],"only":["quickfix"]}}

[Error - Received] 23:25:29.428 PM #12 no PackageHandles

[Error - 11:25:29 PM] Request textDocument/codeAction failed.
Message: no PackageHandles
Code: 0
[Trace - 23:25:29.428 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/06/16 23:25:29 go/packages.Load\n\tsnapshot=1\n\tdirectory=/usr/local/path/to/my/go/code\n\tquery=[file=/usr/local/path/to/my/go/code/example.go]\n\tpackages=0\n"}

[Info - 11:25:29 PM] 2020/06/16 23:25:29 go/packages.Load
snapshot=1
directory=/usr/local/path/to/my/go/code
query=[file=/usr/local/path/to/my/go/code/example.go]
packages=0

@gopherbot gopherbot added the Tools label Jun 16, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 16, 2020

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.

@gopherbot gopherbot added the gopls label Jun 16, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 16, 2020
@zhuzeng
Copy link
Author

@zhuzeng zhuzeng commented Jun 16, 2020

Forgot to mention the gopls version:

$ gopls version
golang.org/x/tools/gopls 0.4.1
    golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
@zhuzeng
Copy link
Author

@zhuzeng zhuzeng commented Jun 16, 2020

gopls -rpc.trace -v check example.go
2020/06/16 23:40:15 Info:2020/06/16 23:40:15 Build info
----------
golang.org/x/tools/gopls 0.4.1
    golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
    golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
    golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info
-------
go version go1.14.4 linux/amd64


2020/06/16 23:40:15 Info:2020/06/16 23:40:15 go/packages.Load
	snapshot=0
	directory=/usr/local/path/to/my/go/code
	query=[./... builtin]
	packages=0
2020/06/16 23:40:15 Info:2020/06/16 23:40:15 go env for 
(valid build configuration = true)
(build flags: [-modfile=/tmp/go.generic-controllers.963344136.mod])
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/xxx"
GOENV="/xxx"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/local/google/home/zhuzenglu/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/google-golang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/xxx"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/usr/local/path/to/my/go/code/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=/tmp/go-build032059510=/tmp/go-build -gno-record-gcc-switches"

2020/06/16 23:40:17 Info:2020/06/16 23:40:17 go/packages.Load
	snapshot=1
	directory=/usr/local/path/to/my/go/code
	query=[file=/usr/local/path/to/my/go/code/example.go]
	packages=0
2020/06/16 23:40:17 Info:2020/06/16 23:40:17 go/packages.Load
	snapshot=1
	directory=/usr/local/path/to/my/go/code
	query=[file=/usr/local/path/to/my/go/code/example.go]
	packages=0
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 17, 2020

I notice from your bio that you're a Googler. We had an issue that I'd be happy to discuss further internally, but the temporary workaround for this is to set GOPACKAGESDRIVER=off in your environment.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Jun 17, 2020
@stamblerre stamblerre closed this Jun 17, 2020
@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v0.4.2 Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.