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 using experimentalWorkspaceModule: expected 1 module, got 2 #41725

Closed
findleyr opened this issue Oct 1, 2020 · 5 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.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Oct 1, 2020

Just got this panic a couple times at master, while using experimentalWorkspaceModule and working on x/tools. Haven't looked into it yet.

panic: unsupported use of -modfile, expected 1 module, got 2                                                                                      
                                                                                                                                                  
goroutine 582872 [running]:                                              
golang.org/x/tools/internal/lsp/cache.(*snapshot).load(0xc029a0d8c0, 0x1048660, 0xc013ed23f0, 0xc00d5d68c0, 0x3, 0x4, 0x0, 0x0)
        /usr/local/google/home/rfindley/src/tools/internal/lsp/cache/load.go:117 +0x2d0d                  
golang.org/x/tools/internal/lsp/cache.(*snapshot).initialize.func2()                                                                              
        /usr/local/google/home/rfindley/src/tools/internal/lsp/cache/view.go:770 +0x470                   
sync.(*Once).doSlow(0xc01b647260, 0xc0239256f8)                                                                                                   
        /usr/lib/google-golang/src/sync/once.go:66 +0xec                                                                                          
sync.(*Once).Do(...)                                                     
        /usr/lib/google-golang/src/sync/once.go:57                                                                                                
golang.org/x/tools/internal/lsp/cache.(*snapshot).initialize(0xc029a0d8c0, 0x10485a0, 0xc00c5010c0, 0xc00ef64e01)
        /usr/local/google/home/rfindley/src/tools/internal/lsp/cache/view.go:729 +0x1d5
golang.org/x/tools/internal/lsp/cache.(*Session).createView.func3(0xc029a0d8c0, 0x10485a0, 0xc00c5010c0, 0xc00ef65190)
        /usr/local/google/home/rfindley/src/tools/internal/lsp/cache/session.go:237 +0x45
created by golang.org/x/tools/internal/lsp/cache.(*Session).createView                                                                            
        /usr/local/google/home/rfindley/src/tools/internal/lsp/cache/session.go:236 +0x9d0                
exit status 2

CC @stamblerre @heschik

@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 Oct 1, 2020
@gopherbot gopherbot added this to the Unreleased milestone Oct 1, 2020
@stamblerre
Copy link
Contributor

Hm, we must have somehow found two modules but not set workspaceMode to useWorkspaceModule--https://github.com/golang/tools/blob/e57f6d466a487e9c19a486ad98e20048ea425bc8/internal/lsp/cache/load.go#L91.

This does make me realize that we add to the modules map unconditionally when things change rather than checking ExperimentalWorkspaceModule, but not relevant here.

@stamblerre
Copy link
Contributor

@pjweinb has been able to reproduce this by opening the src directory of the golang/go repository.

@findleyr
Copy link
Contributor Author

findleyr commented Oct 5, 2020

🤦 it's likely that I was doing the same thing. Thanks Peter for doing a better job of investigating!

@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.5.2 Oct 5, 2020
@stamblerre stamblerre self-assigned this Oct 5, 2020
@stamblerre
Copy link
Contributor

The issue is that go/src and go/src/cmd have vendor directories, so we don't use the workspace module, but we still have 2 modules in the snapshot's modules. We should probably disqualify modules with vendor directories earlier.

@gopherbot
Copy link

Change https://golang.org/cl/259623 mentions this issue: internal/lsp: revert back to one module per view with vendoring

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

No branches or pull requests

3 participants