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: panic with invalid go.mod entry #35599

Closed
muirdm opened this issue Nov 14, 2019 · 2 comments
Labels
Milestone

Comments

@muirdm
Copy link

@muirdm muirdm commented Nov 14, 2019

I was playing around with my go.mod for personal reasons and had left it with an invalid "require":

module foo

go 1.13

require example.com/foo v1.2.3-456

gopls panics on startup after the "go list" error.

[Trace - 03:09:47 PM] Received notification 'window/logMessage'.
Params: {
  "message": "2019/11/14 15:09:47 : error loading packages: go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./...]: exit status 1: go: example.com/foo@v1.2.3-456: unrecognized import path \"example.com/foo\" (parse https://example.com/foo?go-get=1: no go-import meta tags ())\n",
  "type": 1
}
panic: runtime error: index out of range [0] with length 0

goroutine 52 [running]:
golang.org/x/tools/internal/lsp/cache.(*session).bestView(0xc0000eda20, 0xc0003a6630, 0x25, 0x0, 0x0)
	/Users/muir/projects/tools/internal/lsp/cache/session.go:226 +0x18f
golang.org/x/tools/internal/lsp/cache.(*session).DidOpen(0xc0000eda20, 0x19b32c0, 0xc00026d380, 0xc0003a6630, 0x25, 0x0, 0x4010000000000000, 0xc0003741e0, 0x51, 0x60, ...)
	/Users/muir/projects/tools/internal/lsp/cache/session.go:294 +0x2be
golang.org/x/tools/internal/lsp.(*Server).didOpen(0xc000265200, 0x19b32c0, 0xc00026d380, 0xc00034e2c0, 0x0, 0xc0003722c0)
	/Users/muir/projects/tools/internal/lsp/text_synchronization.go:30 +0x18c
golang.org/x/tools/internal/lsp.(*Server).DidOpen(0xc000265200, 0x19b32c0, 0xc00026d380, 0xc00034e2c0, 0xc00034e2c0, 0x0)
	/Users/muir/projects/tools/internal/lsp/server.go:135 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver(0x19cc840, 0xc000265200, 0x19b32c0, 0xc00026d380, 0xc000272bc0, 0xc00026d300, 0xc00020ec80)
	/Users/muir/projects/tools/internal/lsp/protocol/tsserver.go:111 +0x1b66
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc0000dcba0, 0xc000272bc0, 0xc000265260, 0x19b32c0, 0xc00026d380, 0x0, 0x0, 0xc000213730)
	/Users/muir/projects/tools/internal/jsonrpc2/jsonrpc2.go:370 +0x170
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
	/Users/muir/projects/tools/internal/jsonrpc2/jsonrpc2.go:354 +0x877
@gopherbot gopherbot added this to the Unreleased milestone Nov 14, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 14, 2019

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 15, 2019

Change https://golang.org/cl/207344 mentions this issue: internal/lsp: fix panic in bestView

gopherbot pushed a commit to golang/tools that referenced this issue Nov 16, 2019
Rather than panicking when we have not created any views for the packages,
we should show a reasonable error to the user. This change propagates the
errors to the user.

Updates golang/go#35599

Change-Id: I49789d8ce18e154f111bc3584488f468a129e30c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/207344
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
@stamblerre stamblerre closed this Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.