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: no package found for [...] #32667

Closed
Asarew opened this issue Jun 18, 2019 · 26 comments
Closed

x/tools/gopls: no package found for [...] #32667

Asarew opened this issue Jun 18, 2019 · 26 comments
Labels
Milestone

Comments

@Asarew
Copy link

@Asarew Asarew commented Jun 18, 2019

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

$ go version 1.12.6

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/asare/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/asare/go"
GOPROXY=""
GORACE=""
GOROOT="/home/asare/.gvm/gos/go1.12.6"
GOTMPDIR=""
GOTOOLDIR="/home/asare/.gvm/gos/go1.12.6/pkg/tool/linux_amd64"
GCCGO="gccgo"
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/go-build578927956=/tmp/go-build -gno-record-gcc-switches"

What did you do?

goto definition

What did you expect to see?

Goto the definition

What did you see instead?


[Error - 3:49:40 PM] unable to check package for file:///home/asare/Projects/skepelton/micro/node.go: loadParseTypeCheck: no package found for /home/asare/Projects/skepelton/micro/node.go
[Error - 3:49:40 PM] unable to check package for file:///home/asare/Projects/skepelton/micro/node.go: loadParseTypeCheck: no package found for /home/asare/Projects/skepelton/micro/node.go
[Error - 3:49:40 PM] Request textDocument/definition failed.
  Message: no AST for file:///home/asare/Projects/skepelton/micro/node.go
  Code: 0 
[Trace - 3:49:40 PM] Sending request 'textDocument/definition - (29)'.
Params: {"textDocument":{"uri":"file:///home/asare/Projects/skepelton/micro/node.go"},"position":{"line":308,"character":21}}


[Trace - 3:49:40 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///home/asare/Projects/skepelton/micro/node.go: loadParseTypeCheck: no package found for /home/asare/Projects/skepelton/micro/node.go"}


[Trace - 3:49:40 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///home/asare/Projects/skepelton/micro/node.go: loadParseTypeCheck: no package found for /home/asare/Projects/skepelton/micro/node.go"}


[Error - 3:49:40 PM] send textDocument/definition#29 no AST for file:///home/asare/Projects/skepelton/micro/node.go


[Error - 3:49:40 PM] unable to check package for file:///home/asare/Projects/skepelton/micro/node.go: loadParseTypeCheck: no package found for /home/asare/Projects/skepelton/micro/node.go
[Error - 3:49:40 PM] unable to check package for file:///home/asare/Projects/skepelton/micro/node.go: loadParseTypeCheck: no package found for /home/asare/Projects/skepelton/micro/node.go
[Error - 3:49:40 PM] Request textDocument/definition failed.
  Message: no AST for file:///home/asare/Projects/skepelton/micro/node.go
  Code: 0 
@gopherbot gopherbot added this to the Unreleased milestone Jun 18, 2019
@gopherbot gopherbot added the gopls label Jun 18, 2019
@Asarew

This comment has been minimized.

Copy link
Author

@Asarew Asarew commented Jun 18, 2019

This hapends after a while of usage (~2min), i've made sure that i'm running the latest version of gopls.
Reloading gopls will "fix" the issue for another ~2min.

@blixt

This comment has been minimized.

Copy link
Contributor

@blixt blixt commented Jun 18, 2019

I'm having a similar issue (my project is using modules):

[Info  - 4:05:41 PM] Build info
----------
version v0.1.0-cmd.gopls, built in $GOPATH mode

Go info
-------
go version go1.12.6 darwin/amd64

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/blixt/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/blixt/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.6/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.6/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/t5/ypbxvct52csdbl1z5kfcrl280000gn/T/go-build019616314=/tmp/go-build -gno-record-gcc-switches -fno-common"

[Error - 4:05:42 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:42 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:42 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:43 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:43 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:44 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:44 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:44 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/blixt/src/github.com/…/src/server/project/project.go
  Code: 0 
[Error - 4:05:44 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:45 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:45 PM] Request textDocument/documentLink failed.
  Message: no AST for file:///Users/blixt/src/github.com/…/src/server/project/project.go
  Code: 0 
[Error - 4:05:45 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:45 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:45 PM] Request textDocument/documentLink failed.
  Message: no AST for file:///Users/blixt/src/github.com/…/src/server/project/project.go
  Code: 0 
[Error - 4:05:46 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:46 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:46 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:46 PM] unable to check package for file:///Users/blixt/src/github.com/…/src/server/project/project.go: go/packages.Load: no packages found for /Users/blixt/src/github.com/…/src/server/project/project.go
[Error - 4:05:46 PM] Request textDocument/hover failed.
  Message: no AST for file:///Users/blixt/src/github.com/…/src/server/project/project.go
  Code: 0 
@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Jun 18, 2019

Just to confirm, @Asarew and @blixt, you are both not using modules and you are opening directories in your $GOPATHs?

@Asarew

This comment has been minimized.

Copy link
Author

@Asarew Asarew commented Jun 19, 2019

I'm using modules, and have a valid go.mod file in my dir

@jkomyno

This comment has been minimized.

Copy link

@jkomyno jkomyno commented Jun 19, 2019

I'm facing the same issue here. I'm using Go1.12.6 with a valid go.mod in the root directory of the project

@blixt

This comment has been minimized.

Copy link
Contributor

@blixt blixt commented Jun 19, 2019

I'm also using modules. I keep my module projects outside my GOPATH since I couldn't get modules to work properly when mixed.

Another problem is that the gopls service gets stuck using a lot of CPU, my computer's basically running hot whenever I've opened VSCode. Even closing VSCode the gopls service runs until I force quit it.

@peterhellberg

This comment has been minimized.

Copy link

@peterhellberg peterhellberg commented Jun 19, 2019

@Asarew Is the file you get the “no AST for” error for reside behind a build tag?
(Me and a colleague are trying to triage this issue, and the problem seemed to be present in projects containing files with build tags)

@Asarew

This comment has been minimized.

Copy link
Author

@Asarew Asarew commented Jun 19, 2019

Noo, the file or package doesn't contain any build tags.

@blixt

This comment has been minimized.

Copy link
Contributor

@blixt blixt commented Jun 19, 2019

I don't have any build tags either. It seems to always error for the same file, but as I've been refactoring a bit the error switched to another file, but the code in the file is very simple (constants, variables and a few functions). It's erroring on a loop for the currently open file in VSCode.

@Asarew

This comment has been minimized.

Copy link
Author

@Asarew Asarew commented Jun 19, 2019

i didn't had any problems all morning, until i started to run some tests (basic go test [...] --count=1 -run).
The way i can reproduce this error localy atleast is by running a test and after triggering a goto definition.

@Asarew

This comment has been minimized.

Copy link
Author

@Asarew Asarew commented Jun 19, 2019

When i was trying to find a fix for this issue i found a long standing bug that resulted in the same error #31553. But i'm not making any changes to the directory outside of vs-code. Does a go test maybe trigger something that it shouldn't?

@jBugman

This comment has been minimized.

Copy link

@jBugman jBugman commented Jun 19, 2019

I have the same issue in a project where Go part is in the subfolder. Simplified structure is:

project/
    backend/ – Go part
    src/ – JS part (may be important ?)
    *.dot-files

gopls fails with a mentioned error if I try to open Go files in the project as a whole, but works perfectly if I do code . in the backend folder (so I have Go at a workspace root)

@Asarew

This comment has been minimized.

Copy link
Author

@Asarew Asarew commented Jun 19, 2019

I don't have the same setup as @jBugman, my go.mod is located in the project root of vscode

@myitcv

This comment has been minimized.

Copy link
Member

@myitcv myitcv commented Jun 19, 2019

I'm seeing this in a module context. In my situation, there are a number of relatively rapid changes to certain files (a code generator is the source of the changes, but the changes are notified to gopls via didChange notifications).

I first see a number of lines like:

unable to check package for file:///path/to/file.go: context canceled

I also see a number of lines like:

failed to deliver diagnostic for file:///path/to/file.go (will retry): context canceled

Then I see a number of lines like:

unable to check package for file:///path/to/file.go: loadParseTypeCheck: no package found for /path/to/file.go

I also see a number of lines like:

file:///path/to/file.go is not part of a package

I don't yet have a repro for this.


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

$ go version
go version go1.12.6 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20190618233249-04b924abaa25
$ go list -m golang.org/x/tools/gopls
golang.org/x/tools/gopls v0.0.0-20190618233249-04b924abaa25

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN="/home/myitcv/gostuff/src/github.com/myitcv/govim/cmd/govim/.bin"
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPROXY=""
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build453321011=/tmp/go-build -gno-record-gcc-switches"
@myitcv

This comment has been minimized.

Copy link
Member

@myitcv myitcv commented Jun 19, 2019

FWIW this was also an issue with:

golang.org/x/tools v0.0.0-20190612231717-10539ce30318
golang.org/x/tools/gopls v0.1.0
@xinglsh6937

This comment has been minimized.

Copy link

@xinglsh6937 xinglsh6937 commented Jun 19, 2019

same problem with @Asarew

@hbobenicio

This comment has been minimized.

Copy link

@hbobenicio hbobenicio commented Jun 19, 2019

same here... tried to downgrade go to 1.11.11 and recreate my GOPATH... the issue still happens.
I've recently updated vscode though. Any thoughts if it can be an issue with recent versions of go vs code plugin for the latest vs code? I can try downgrading my vscode later (when I have more free time) just to check it.

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Jun 19, 2019

@Asarew: Running the go command can modify your go.mod file, but I'm not sure if it would be likely to affect gopls in this case. In the go env output you provided, the GOMOD variable was not set - can you run go env in your project's directory, or can you provide the full contents of your gopls log (including the top part that prints the go env)? Can you also confirm that you are seeing the error with the latest version of gopls (you can install it by running go get -u golang.org/x/tools/gopls@latest)?

@blixt: Based on your go env output in your gopls log, it seems that there is no GOMOD set, which would likely be the cause of your problem. Are you opening VSCode from the directory where the go.mod file is located?

@hbobenicio: Updating the VSCode-Go extension should not be necessary, but you can get the latest version of gopls by running go get -u golang.org/x/tools/gopls@latest.

Just to reiterate, if you are using gopls with modules, you have to open VSCode with the directory that contains the go.mod file, i.e. the module root. More details here: #32394.

@blixt

This comment has been minimized.

Copy link
Contributor

@blixt blixt commented Jun 19, 2019

@stamblerre Only opening the folder with the Go code does seem to work better, but I can't really work like that in my setup so I'll turn off use of the language server.

I'm a bit surprised that this is a known limitation but there are no error messages implying what the problem is and gopls uses lots of CPU (to the point that the computer is running very hot).

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Jun 19, 2019

@blixt: You can use File -> Add Folder to Workspace to create a workspace with multiple folders, and this will work fine with gopls. We are working on exposing better error messages from gopls. The issue here is that we use go list to get the module information, and go list does not provide very descriptive errors. gopls would run hot in this case, because it will continuously re-try running go list to see if the environment has changed. We are working on improvements to change this behavior.

@Asarew

This comment has been minimized.

Copy link
Author

@Asarew Asarew commented Jun 20, 2019

@stamblerre I've done absolutely nothing but I'm unable to trigger the same error this morning. I'll keep on working with my current configuration this week. If nothing happens I'll assume the cause of the error as a PEBCAK and close the issue.

@jbrodriguez

This comment has been minimized.

Copy link

@jbrodriguez jbrodriguez commented Jun 20, 2019

I have a setup similar to #32667 (comment), that is go.mod isn't at the project root.

I can confirm that both 'workarounds' suggested by @stamblerre work

  • Open VSCode in the folder that contains go.mod
  • Open VSCode in my project root, then add the folder that contains go.mod as workspace

Although it works, hopefully the root cause(s) get solved

@myitcv

This comment has been minimized.

Copy link
Member

@myitcv myitcv commented Jun 20, 2019

@Asarew

If nothing happens I'll assume the cause of the error as a PEBCAK and close the issue.

Please keep the issue open, even if you're not able to reproduce it. I have reproduction steps (it's somewhat timing related) and have privately shared logs with @stamblerre and @ianthehat

@tonyghita

This comment has been minimized.

Copy link

@tonyghita tonyghita commented Jun 27, 2019

I am observing this issue upon starting VS Code in a GOPATH based project (not use modules), on a *_test.go file which is not in the _test package, but the normal package.

go version go1.12.6 darwin/amd64
version v0.1.0, built in $GOPATH mode

On commit ba023a1bc99eeb4f4a1791af897917fd8b046629.

This is also paired with an error message

could not find token.File for diagnostic: file://the-file-packages-were-not-found

EDIT: moved to a separate issue #32812

@hbobenicio

This comment has been minimized.

Copy link

@hbobenicio hbobenicio commented Jul 2, 2019

In my case the problem after all was that my GOPATH was messed up.

Following this tip I just removed my GOPATH (in my case it was the default ~/go) and vscode plugin reinstalled my gopls and other tools and know everything works fine!

@stamblerre stamblerre changed the title x/tools/cmd/gopls: no package found for [...] x/tools/gopls: no package found for [...] Jul 2, 2019
@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Jul 2, 2019

Filed @myitcv's issue separately (#32899). Closing this for now, as most of these errors should resolved with the latest version of gopls.

@stamblerre stamblerre closed this Jul 2, 2019
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
You can’t perform that action at this time.