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: provide a way to suppress “failed to compile” notifications #40825

Closed
josharian opened this issue Aug 16, 2020 · 16 comments
Closed
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.
Milestone

Comments

@josharian
Copy link
Contributor

This warning pops up constantly for me, often several times a minute. There is no way I see to dismiss it permanently. I don't know what's wrong, and usually I don't care; I'm in the midst of typing or doing other work and it is a distraction. It always seems to recover by itself.

I'd love some way to suppress the notification, maybe a setting or a button in the notification itself. If set, maybe the "failed to compile" message, with useful detail, could go to the console instead, which is where I go looking if things aren't working as expected.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 16, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 16, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v.0.5.0 Aug 17, 2020
@stamblerre
Copy link
Contributor

This error only pops up if gopls is in a bad enough state that we haven't been able to load any information for the packages in your workspace. It's almost meant to be annoying because we want the user to pay attention to it, but we are considering changing the frequency with which it pops up (https://golang.org/cl/248623).

Do you mind sharing your logs when you see this error? I really would not expect it to appear frequently if things are working correctly.

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 17, 2020
@josharian
Copy link
Contributor Author

I just started a different project, so this might not have the same root cause as before, but I'll just dump all instances here as they occur.

The code in the workspace failed to compile (see the error message below). If you believe this is a mistake, please file an issue: https://github.com/golang/go/issues/new. github.com/josharian/native [github.com/josharian/native.test] has no metadata

No output at all for gopls. gopls server has a bunch of entries like this:

[Trace - 10:06:44.652 AM] Sending request 'textDocument/codeLens - (409)'.
Params: {"textDocument":{"uri":"file:///Users/josh/src/github.com/josharian/native/endian.go"}}


[Trace - 10:06:44.652 AM] Received response 'textDocument/codeLens - (409)' in 0ms.
Result: null


[Trace - 10:06:44.653 AM] Sending request 'textDocument/codeAction - (410)'.
Params: {"textDocument":{"uri":"file:///Users/josh/src/github.com/josharian/native/endian.go"},"range":{"start":{"line":4,"character":19},"end":{"line":4,"character":19}},"context":{"diagnostics":[]}}


[Trace - 10:06:44.653 AM] Received response 'textDocument/codeAction - (410)' in 0ms.
Result: null

Under problems, I see:

{
	"resource": "/Users/josh/src/github.com/josharian/native/endian_test.go",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "package native_test; expected native",
	"source": "compiler",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 8
}

and

{
	"resource": "/Users/josh/src/github.com/josharian/native/endian_generic.go",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "undeclared name: binary",
	"source": "compiler",
	"startLineNumber": 3,
	"startColumn": 14,
	"endLineNumber": 3,
	"endColumn": 30
}

The first "problem" is bogus--native_test is a legitimate package name for an external test in a package called native.

The second "problem" is bogus--it is complaining about a line that reads import "encoding/binary".

@heschi
Copy link
Contributor

heschi commented Aug 19, 2020

@josharian We need the full log, I'm afraid.

This might be a dupe of #40578 if you have a folder with no Go code in it and GO111MODULE=on.

@josharian
Copy link
Contributor Author

Where should I look for the full log?

GO111MODULE is unset; there is Go code present.

@heschi
Copy link
Contributor

heschi commented Aug 19, 2020

@josharian
Copy link
Contributor Author

I created a new directory, then ran

$ touch x.go
$ touch x_test.go
$ code .

I opened x.go and typed package p and hit save. I opened x_test.go and typed package p_test and hit save. Even before I managed to hit save on x_test.go, the compilation failed message started popping up.

Logs:

https://gist.github.com/josharian/e997023e436db031dba79a90249a9c9f

@heschi
Copy link
Contributor

heschi commented Aug 19, 2020

I can't reproduce. Before I dig any further, it might be worth trying 1.15, which fixed a number of bugs related to partial/missing package declarations. Can you update and make sure it's first on your PATH when you start VS Code?

@josharian
Copy link
Contributor Author

Still reproduces with 1.15, exactly the same set of steps.

https://gist.github.com/josharian/6021b95602f3ae70820bf20ec80147ee

I noticed that this reproducer happened to be located as a GOPATH subdir. Sorry for not mentioning that earlier. I have also hit the same set of symptoms outside of GOPATH, so it didn't occur to me as relevant, but maybe there are multiple different things happening.

@zhaohanweng
Copy link

I am able to reproduce this consistently in vscode.

  1. Create a new workspace,
  2. add the go project (Add folder to workspace)
  3. add another non go project (Add folder to workspace)
  4. Go to go project and try to edit and save
  5. You will see the warning.

when it's only go project in the workspace, there will not be any warning when editing go files.
once another project is added, the warning will show up in the go project.

@heschi
Copy link
Contributor

heschi commented Aug 20, 2020

@zhaohanweng That is #40578. Please see #40578 (comment).

@heschi
Copy link
Contributor

heschi commented Aug 21, 2020

OK, yes, this seems to be a GOPATH-specific bug in some mix of the go command and go/packages.

@stamblerre seems to enjoy enabling this popup and then fixing go/packages edge cases, so perhaps she'll have something to say here.

@gopherbot
Copy link

Change https://golang.org/cl/249703 mentions this issue: internal/lsp/regtest: reproduce empty xtest bug

gopherbot pushed a commit to golang/tools that referenced this issue Aug 21, 2020
packages.Load returns bad data for an empty xtest in GOPATH mode.

Updates golang/go#40825.

Change-Id: Ibab8dcbeafc22a71a2a4c3be0008b728c13c4c80
Reviewed-on: https://go-review.googlesource.com/c/tools/+/249703
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@stamblerre
Copy link
Contributor

Thanks for investigating this, @heschik. This is similar to a number of bugs we've seen with empty files--all related to #39986. The go/packages fix here is likely not feasible, so I think the full resolution to this issue will have to come with #39986, which will hopefully be released as part of Go 1.16. In the meantime, I will mail a CL to disable the pop-up.

@gopherbot
Copy link

Change https://golang.org/cl/250949 mentions this issue: internal/lsp, go/packages: work-around invalid files in GOPATH mode

@stamblerre stamblerre removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 27, 2020
@josharian
Copy link
Contributor Author

josharian commented Sep 2, 2020

@stamblerre I am now getting these pop-ups in another project. I just re-installed gopls at HEAD, or at least, I tried to. Should I...open a new issue? Do something else?

@stamblerre
Copy link
Contributor

I just re-installed gopls at HEAD, or at least, I tried to.

What's the output of gopls version? To install at HEAD, run GO111MODULE=on go get golang.org/x/tools/gopls@master golang.org/x/tools@master. If that doesn't fix the issue, feel free to open a new issue and please attach the contents of the error message and your logs.

@golang golang locked and limited conversation to collaborators Sep 2, 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.
Projects
None yet
Development

No branches or pull requests

5 participants