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: error loading workspace: no metadata for ... #43004

Closed
vishalkanaujia opened this issue Dec 4, 2020 · 11 comments
Closed

x/tools/gopls: error loading workspace: no metadata for ... #43004

vishalkanaujia opened this issue Dec 4, 2020 · 11 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@vishalkanaujia
Copy link

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

$ go version
go version go1.14.12 darwin/amd64

Does this issue reproduce with the latest release?

Yes!

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

Mac OS 11.0.1

go env Output
$ go env
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xxx/Library/Caches/go-build"
GOENV="/Users/xxx/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY="bitbucket.org"
GONOSUMDB="bitbucket.org"
GOOS="darwin"
GOPATH="/Users/xxx/go/"
GOPRIVATE="bitbucket.org"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
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/2q/tjh8ff852379vjlzgz_fww480000gn/T/go-build239085011=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  • built the project from the root of the monorepo.

What did you expect to see?

No error from go extension.

What did you see instead?

The error caused the disable of source navigation to definitions/implementations.

@stamblerre stamblerre changed the title Error loading workspace: no metadata for ... x/tools/gopls: error loading workspace: no metadata for ... Dec 4, 2020
@stamblerre
Copy link
Contributor

Can you please share a gopls log? Instructions on how to capture one here: https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs.

@stamblerre stamblerre added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Dec 4, 2020
@stamblerre stamblerre added this to the gopls/vscode-go milestone Dec 4, 2020
@stamblerre stamblerre added this to Waiting for Info in vscode-go: gopls by default Dec 4, 2020
@vishalkanaujia
Copy link
Author

[Error - 11:20:37 PM] 2020/12/07 23:20:37 warning: diagnose go.mod: no metadata for bitbucket.org/<monorepo>/type [bitbucket.org/<monorepo>/type.test]
	directory=<GOPATH>/src/goprivate/monorepo
	snapshot=365
  • VSCode is using root of the monorepo as workspace.

@stamblerre
Copy link
Contributor

stamblerre commented Dec 7, 2020

Thanks, @vishalkanaujia -- did bitbucket.org/<monorepo>/type or its test get deleted between the branches? There is a bug that will be fixed in v0.6.0 by https://golang.org/cl/275273. Can you please try building gopls with that patch to see if that fixes the issue? You can do so by following these steps.

$ git clone https://go.googlesource.com/tools
$ cd tools
$ git fetch https://go.googlesource.com/tools refs/changes/73/275273/1 && git cherry-pick FETCH_HEAD
$ cd gopls
$ go install

@takeyourhatoff
Copy link

Thanks, @vishalkanaujia -- did bitbucket.org/<monorepo>/type or its test get deleted between the branches? There is a bug that will be fixed in v0.6.0 by https://golang.org/cl/275273. Can you please try building gopls with that patch to see if that fixes the issue? You can do so by following these steps.

$ git clone https://go.googlesource.com/tools
$ cd tools
$ git fetch https://go.googlesource.com/tools refs/changes/73/275273/1 && git cherry-pick FETCH_HEAD
$ cd gopls
$ go install

This didn't fix the issue for me, although it might just be my GOPRIVATE modules affected now.

@stamblerre
Copy link
Contributor

@takeyourhatoff: If you don't mind, could you file a new issue following the steps here: https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs? It's usually easier to investigate different issues separately.

@vishalkanaujia
Copy link
Author

Thanks, @vishalkanaujia -- did bitbucket.org/<monorepo>/type or its test get deleted between the branches? There is a bug that will be fixed in v0.6.0 by https://golang.org/cl/275273. Can you please try building gopls with that patch to see if that fixes the issue? You can do so by following these steps.

$ git clone https://go.googlesource.com/tools
$ cd tools
$ git fetch https://go.googlesource.com/tools refs/changes/73/275273/1 && git cherry-pick FETCH_HEAD
$ cd gopls
$ go install

I still get the same errors.

[Error - 12:06:17 PM] 2020/12/08 12:06:17 errors diagnosing workspace: no metadata for bitbucket.org/<monorepo>/mycurrency [bitbucket.org/<monorepo>/mycurrency.test]
	snapshot=37
	directory=file://<$GOPATH>/src/goprivate/xxx

@stamblerre
Copy link
Contributor

Would you be able to share a complete log (starting from the initialize message)? I understand that might be difficult to anonymize, so if you'd prefer to share it privately, that could work too.

Alternatively, if you're able to reproduce this consistently, maybe you could describe the characteristics of your workspace and see if we can construct a public repro example.

@vishalkanaujia
Copy link
Author

I hit the problem again. I have sent you a mail with log details. The problem disappears after restarting VSCode.

@stamblerre
Copy link
Contributor

Can you please make sure to add the following to your settings?

"go.languageServerFlags": [
	"-rpc.trace",
]

The logs you attached are missing some detail. Also, it looks like your workspace root is not a module, and it is outside of $GOPATH/src. I would recommend opening a module or a subdirectory of $GOPATH/src.

@vishalkanaujia
Copy link
Author

Thanks for the recommendations. I think the gopls behavior is correct if the monorepo is placed in the $GOPATH/src/ or just the module of the subdirectory is opened in the editor.

@stamblerre
Copy link
Contributor

Yep, that is correct--gopls doesn't work well if you open your entire GOPATH. More details can be found here: #36899. Going to close this issue since it's been resolved.

vscode-go: gopls by default automation moved this from Waiting for Info to Done Dec 12, 2020
@stamblerre stamblerre removed this from the gopls/vscode-go milestone Dec 14, 2020
@golang golang locked and limited conversation to collaborators Dec 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
No open projects
Development

No branches or pull requests

4 participants