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: 0.4.4 undeclared name errors on valid code #40553

Closed
andig opened this issue Aug 3, 2020 · 18 comments
Closed

x/tools/gopls: 0.4.4 undeclared name errors on valid code #40553

andig opened this issue Aug 3, 2020 · 18 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.
Milestone

Comments

@andig
Copy link
Contributor

andig commented Aug 3, 2020

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

$ go version
go version go1.14.6 darwin/amd64

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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.6/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.6/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/mbmd/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/73/89ycv7qn51j4kbm04jsz9b840000gn/T/go-build854369359=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Upgrade gopls when prompted by vscode

What did you expect to see?

Smooth coding as before

What did you see instead?

Lots of undeclared name: xyz errors in vscode and generally high CPU usage when using the go plugin. The code itself is fine and compiles on the command line.

Raising here as this happened immediately after upgrading gopls from 0.4.3 to 0.4.4. Tools have been reinstalled.

@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 3, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 3, 2020
@rsikdar
Copy link

rsikdar commented Aug 3, 2020

I'm also having issues with gopls after upgrading to 0.4.4 today.
Autocompletion and definitions are gone for me (except for basic text completion), and no syntax highlighting/errors show up at all no matter what I type. In my case, gopls does not have high CPU usage.

@heschi
Copy link
Contributor

heschi commented Aug 4, 2020

@andig: Please follow the troubleshooting instructions at https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md to capture logs, upload them here, and we'll take a look.

@rsikdar please do the same, but file a new issue rather than adding to this one. Similar symptoms can have different causes and it's better to keep them separate for now.

@apang1992
Copy link

gopls 0.4.4 consumes tons of memory!

@heschi
Copy link
Contributor

heschi commented Aug 4, 2020

@apang1992 Please follow the instructions above and file a new issue and we'll take a look.

@andig
Copy link
Contributor Author

andig commented Aug 4, 2020

Here's the gopls server log- not much so see https://pastebin.com/tEQwYS3p. Is this what is required?

@mrunhap
Copy link

mrunhap commented Aug 4, 2020

gopls 0.4.4 consumes tons of memory!

@andig andig changed the title x/tools/gopls: 0.4.4 broken? x/tools/gopls: 0.4.4 undeclared name errors on valid code Aug 4, 2020
@andig
Copy link
Contributor Author

andig commented Aug 4, 2020

@404CN as written above, please open a separate issue

@andig
Copy link
Contributor Author

andig commented Aug 4, 2020

@heschik while waiting, is there any way to force a downgrade of gopls and tools to get back to a working state?

@jrwren
Copy link

jrwren commented Aug 4, 2020

I'm having similar issues.

I noticed in the 0.4.4 release notes:

  • Support features and diagnostics for the entire module, even when you open a subdirectory of the module.

But I am specifically opening a few packages (vs-code with add-folder-to-workspace) instead of my entire module because my entire module is rather large with a large number of packages. Is there an option to get the old behavior?

@heschi
Copy link
Contributor

heschi commented Aug 4, 2020

@andig instructions to install a specific version are on https://github.com/golang/tools/blob/master/gopls/doc/user.md#installation.

You have an interesting workspace setup and I wonder if it's deliberate. From what I can tell there are two folders, /Users/andig/htdocs/mbmd and /Users/andig/htdocs/forecast. There is a go.mod in mbmd as I would expect, but forecast doesn't have one, and that folder is using a go.mod from htdocs instead. Is there a lot of stuff in htdocs?

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v.0.4.5 Aug 4, 2020
@andig
Copy link
Contributor Author

andig commented Aug 4, 2020

You have an interesting workspace setup and I wonder if it's deliberate.

That's coincidence. All my projects reside in htdocs. My workspace typicially contains a bunch of project root folders, each one with its own go mod. I've removed the stray folder and excess go.mod.

I've downgraded to 0.15.2 and 0.4.3 and upgraded again. Now I've started getting this message:

You are neither in a module nor in your GOPATH. If you are using modules, please open your editor to a directory in your module. If you believe this warning is incorrect, please file an issue: https://github.com/golang/go/issues/new.

Didn't have any problems before gopls 0.4.4

@stamblerre
Copy link
Contributor

Have you added each module to your workspace through View -> Add Folder to Workspace? Currently, gopls does not support opening a directory above a module.

@stamblerre
Copy link
Contributor

@rsikdar, @apang1992, @404CN, @jrwren: Please file new issues so that we can discuss them separately. While the error messages may be the same, the cause of the issues are likely to be different.

@andig
Copy link
Contributor Author

andig commented Aug 5, 2020

Have you added each module to your workspace through View.

Yes.

I have meanwhile downgraded and upgraded again, both vscode extension and gopls. At this time, I'm not seeing errors anymore. One observation I've had is that vscode showed various errors and type hints that indicated it was working from an entirely outdated codebase (eg. old types that don't exist anymore shown in the hints, new types declared unknown).

Is there any type of cache in gopls that could be cleared?

@stamblerre
Copy link
Contributor

You can try the "Go: Restart Language Server" command in VS Code to restart the language server. Do you mind providing an updated log after you deleted the stray go.mod file?

@andig
Copy link
Contributor Author

andig commented Aug 6, 2020

Do you mind providing an updated log after you deleted the stray go.mod file?

Not at all, thank you for the intensive care. Here's an updated log: https://pastebin.com/U7yR8C2W. I'm still (or again) seeing problems for things that compile fine:

handler.Timeout undefined (type *ASCIIClientHandler has no field or method Timeout)

Update not sure this one should compile, it doesn't on the command line either although that package most definitely exists, so not sure if there still is a gopls issue:

❯ make build
go build
serial.go:12:2: cannot find package "github.com/grid-x/serial" in any of:
        /usr/local/Cellar/go/1.14.6/libexec/src/github.com/grid-x/serial (from $GOROOT)
        /Users/andig/go/src/github.com/grid-x/serial (from $GOPATH)
make: *** [build] Error 1

@stamblerre
Copy link
Contributor

The error message looks like you're in GOPATH mode, but I believe you're using modules. Make sure that GO111MODULE does not equal off and that you are within a module when compiling.

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

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

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

No branches or pull requests

8 participants