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/internal/lsp: gopls hangs on a testdata workspace #31194

Closed
bstaletic opened this issue Apr 1, 2019 · 12 comments
Closed

x/tools/internal/lsp: gopls hangs on a testdata workspace #31194

bstaletic opened this issue Apr 1, 2019 · 12 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@bstaletic
Copy link

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

$ go version
go version go1.12.1 linux/amd64

Does this issue reproduce with the latest release?

Yes, I am using the latest go release.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/bstaletic/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/bstaletic/Temp/ycmd/test"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/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-build983012561=/tmp/go-build -gno-record-gcc-switches"

This was also reproduced on Windows.

What did you do?

I am one of the maintainers of ycmd and we wanted to switch from gocode to gopls, however gopls doesn't respond to any requests.

Unfortunately that means the steps to reproduce need to contain instruction on setting up ycmd.

Steps to reproduce:

  • Since ycmd can be used with different editors, I'm going to assume vim.
  • git clone https://github.com/Valloric/YouComplete (use your vim plugin manager)
  • cd YouCompleteMe
  • git submodule update --init --recursive
  • cd third_party/ycmd
  • git remote add bstaletic https://github.com/bstaletic/ycmd && git fetch bstaletic
  • git checkout bstaletic/gopls
  • ./build.py --go-completer
  • vim foo.go
  • Type :YcmCompleter GoTo (or any other :YcmCompleter command)
    • Result: vim hangs until ycmd reports "request timed out"
  • Enter insert mode and press <C-Space> (should display gopls's completion results)
    • Result: Nothing happens.

What did you expect to see?

GOPLS providing completions and other advertised capabilities.

What did you see instead?

Request timeouts and editor hangs.

GOPLS and ycmd logs: https://gist.github.com/bstaletic/57ac9351b356c9266391bcc477f865b4

@stamblerre stamblerre added the gopls Issues related to the Go language server, gopls. label Apr 1, 2019
@stamblerre stamblerre changed the title GOPLS doesn't respond to any request gopls hangs on a testdata workspace Apr 1, 2019
@stamblerre stamblerre changed the title gopls hangs on a testdata workspace x/tools/internal/lsp: gopls hangs on a testdata workspace Apr 1, 2019
@gopherbot gopherbot added this to the Unreleased milestone Apr 1, 2019
@stamblerre
Copy link
Contributor

@bstaletic: do you mind syncing to head and trying again? I broke gopls for about an hour today, and I'm wondering if you maybe just synced to a bad CL. I followed your repro instructions, and it worked for me.

@bstaletic
Copy link
Author

Thanks for looking into this. I have pulled in the latest master and now I do get a response, but it's always the same error.

From ycmd log:

2019-04-02 02:41:30,522 - DEBUG - TX: Sending message: b'Content-Length: 255\r\n\r\n{"id": "2", "jsonrpc": "2.0", "method": "textDocument/definition", "params": {"position": {"character": 1, "line": 8}, "textDocument": {"uri": "file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/go/testdata/test.go"}}}'
2019-04-02 02:41:30,547 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","error":{"code":0,"message":"no file information for file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/go/testdata/test.go","data":null},"id":"2"}'
Traceback (most recent call last):
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 862, in _handle
    return route.call(**args)
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1740, in wrapper
    rv = callback(*a, **ka)
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/watchdog_plugin.py", line 104, in wrapper
    return callback( *args, **kwargs )
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/hmac_plugin.py", line 68, in wrapper
    body = callback( *args, **kwargs )
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/handlers.py", line 82, in RunCompleterCommand
    request_data ) )
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/completers/completer.py", line 350, in OnUserCommand
    return command( self, request_data, arguments[ 1: ] )
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 54, in <lambda>
    lambda self, request_data, args: self.GoTo( request_data, [ 'Definition' ] )
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 1657, in GoTo
    result = self._GoToRequest( request_data, handlers[ 0 ] )
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 1638, in _GoToRequest
    REQUEST_TIMEOUT_COMMAND )[ 'result' ]
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 387, in GetResponse
    return response.AwaitResponse( timeout )
  File "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 195, in AwaitResponse
    error.get( 'message' ) or 'No message' ) )
ycmd.completers.language_server.language_server_completer.ResponseFailedException: Request failed: 0: no file information for file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/go/testdata/test.go

Unfortunately the gopls log is completely empty. Currently on commit:

4c644d7e (HEAD -> master, origin/master, origin/HEAD) internal/lsp: avoid extra work in *cache.View.remove

@stamblerre
Copy link
Contributor

Oh right, forgot that you were in a testdata directory. go list specifically ignores testdata files, so gopls doesn't work on them. Can you try it in another file?

@bstaletic
Copy link
Author

I wish it was that easy. Exactly the same behaviour for file:///home/bstaletic/foo.go - no log and Request failed: 0: no file information for <any URI>.

@stamblerre
Copy link
Contributor

are you using $GOPATH or go modules?

@stamblerre
Copy link
Contributor

stamblerre commented Apr 2, 2019

to get a log, you will want to pass the -logfile flag.

@bstaletic
Copy link
Author

are you using $GOPATH or go modules?

I tried with and without $GOPATH and no module. When I had $GOPATH set, it was set to the same directory that was used for gopls installation, which ends up being ycmd/third_party/go.

to get a log, you will want to pass the -logfile flag.

Even with that flag, the log was 0 bytes.

@stamblerre
Copy link
Contributor

If you're not using Go modules, you will need to have $GOPATH configured correctly. Did the ycmd/third_party/go directory have the expected $GOPATH layout with the src, bin, and pkg directories in it?

@bstaletic
Copy link
Author

ycmd/third_party/go does have src and bin, but there's no pkg, but even if I create ycmd/third_party/go/pkg I still get the "no file information" error.

@stamblerre
Copy link
Contributor

What is the path of the file you are testing on. Is it also in $GOPATH/src? file:///home/bstaletic/foo.go doesn't appear to be.

@bstaletic
Copy link
Author

Ahhh! So that was the problem! golsp works inside $GOPATH. Thanks for helping me figure this out.

@stamblerre
Copy link
Contributor

No problem! Glad it's working.

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

No branches or pull requests

3 participants