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: Error loading workspace folders (expected 1, got 0) #44122

Closed
chaudum opened this issue Feb 5, 2021 · 2 comments
Closed

x/tools/gopls: Error loading workspace folders (expected 1, got 0) #44122

chaudum opened this issue Feb 5, 2021 · 2 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.

Comments

@chaudum
Copy link

chaudum commented Feb 5, 2021

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

$ go version
go version go1.15.7 linux/amd64

Does this issue reproduce with the latest release?

Yes

$ gopls version
golang.org/x/tools/gopls v0.6.5
    golang.org/x/tools/gopls@v0.6.5 h1:kLt9rD/dWtVdvc8LmdcxagDFih6zxYXREpKSYYZu5KE=

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/christian/.cache/go-build"
GOENV="/home/christian/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/christian/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/christian/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/christian/sandbox/chaudum/golang/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build961008458=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I installed gopls via go get, and configured it via nvim-lspconfig:

  lspconfig.gopls.setup{
    cmd = {
      '/home/christian/go/bin/gopls',
      '-v',
      '-rpc.trace',
      '-logfile=/home/christian/gopls.log',
    };
    settings = {
      gopls = {
        -- experimentalWorkspaceModule = true
        -- expandWorkspaceToModule = true,
        analyses = {
          unusedparams = true,
        },
        staticcheck = true,
        codelenses = {
          gc_details = true,
        }
      },
    }

What did you expect to see?

gopls works without errors.

What did you see instead?

Neovim prints an error when opening the file test.go and language server does not do anything.

LSP[gopls] Error loading workspace folders (expected 1, got 0)
failed to load view for file:///home/christian/sandbox/chaudum/golang: failed to get workspace configuration from client (file:///home/christian/sandbox/chaudum/golang): MethodNotFound

gopls logs

cat gopls.log Output
$ cat gopls.log
$ cat gopls.log                                                
[Trace - 11:11:58.190 AM] Sending request 'initialize - (1)'.
Params: {"rootUri": "file:///home/christian/sandbox/chaudum/golang", "initializationOptions": {}, "workspaceFolders": [{"uri": "file:///home/christian/sandbox/chaudum/golang", "name": "/home/christian/sandbox/chaudum/golang"}], "rootPath": "/home/christian/sandbox/chaudum/golang", "processId": 3179162, "trace": "off", "capabilities": {"window": {"workDoneProgress": true}, "workspace": {"workspaceFolders": true, "configuration": true, "symbol": {"symbolKind": {"valueSet": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, "dynamicRegistration": false, "hierarchicalWorkspaceSymbolSupport": true}, "applyEdit": true}, "callHierarchy": {"dynamicRegistration": false}, "textDocument": {"implementation": {"linkSupport": true}, "documentSymbol": {"symbolKind": {"valueSet": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, "dynamicRegistration": false, "hierarchicalDocumentSymbolSupport": true}, "references": {"dynamicRegistration": false}, "signatureHelp": {"signatureInformation": {"documentationFormat": ["markdown", "plaintext"]}, "dynamicRegistration": false}, "rename": {"prepareSupport": true, "dynamicRegistration": false}, "definition": {"linkSupport": true}, "completion": {"completionItem": {"snippetSupport": false, "commitCharactersSupport": false, "preselectSupport": false, "deprecatedSupport": false, "documentationFormat": ["markdown", "plaintext"]}, "contextSupport": false, "dynamicRegistration": false, "completionItemKind": {"valueSet": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}, "codeAction": {"codeActionLiteralSupport": {"codeActionKind": {"valueSet": ["", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports"]}}, "dynamicRegistration": false}, "documentHighlight": {"dynamicRegistration": false}, "hover": {"dynamicRegistration": false, "contentFormat": ["markdown", "plaintext"]}, "synchronization": {"didSave": true, "willSaveWaitUntil": false, "willSave": false, "dynamicRegistration": false}, "declaration": {"linkSupport": true}, "typeDefinition": {"linkSupport": true}}}}

[Trace - 11:11:58.191 AM] Received response 'initialize - (1)' in 0ms.
Result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor.extract","refactor.rewrite","source.fixAll","source.organizeImports"]},"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":{"prepareProvider":true},"foldingRangeProvider":true,"executeCommandProvider":{"commands":["gopls.generate","gopls.fill_struct","gopls.regenerate_cgo","gopls.test","gopls.tidy","gopls.update_go_sum","gopls.undeclared_name","gopls.go_get_package","gopls.check_upgrades","gopls.add_dependency","gopls.upgrade_dependency","gopls.remove_dependency","gopls.vendor","gopls.extract_variable","gopls.extract_function","gopls.gc_details","gopls.generate_gopls_mod"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{"path":"golang.org/x/tools/gopls","version":"v0.6.5","sum":"h1:kLt9rD/dWtVdvc8LmdcxagDFih6zxYXREpKSYYZu5KE=","deps":[{"path":"github.com/BurntSushi/toml","version":"v0.3.1","sum":"h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ="},{"path":"github.com/google/go-cmp","version":"v0.5.4","sum":"h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M="},{"path":"github.com/sergi/go-diff","version":"v1.1.0","sum":"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0="},{"path":"golang.org/x/mod","version":"v0.4.0","sum":"h1:8pl+sMODzuvGJkmj2W4kZihvVb5mKm8pB/X44PIQHv8="},{"path":"golang.org/x/sync","version":"v0.0.0-20201020160332-67f06af15bc9","sum":"h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck="},{"path":"golang.org/x/sys","version":"v0.0.0-20210119212857-b64e53b001e4","sum":"h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k="},{"path":"golang.org/x/tools","version":"v0.1.1-0.20210201201750-4d4ee958a9b7","sum":"h1:/wdPW261t381NDQd8TBo63/FyvACfLICwtH8wMRoHJQ="},{"path":"golang.org/x/xerrors","version":"v0.0.0-20200804184101-5ec99f83aff1","sum":"h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE="},{"path":"honnef.co/go/tools","version":"v0.0.1-2020.1.6","sum":"h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc="},{"path":"mvdan.cc/gofumpt","version":"v0.1.0","sum":"h1:hsVv+Y9UsZ/mFZTxJZuHVI6shSQCtzZ11h1JEFPAZLw="},{"path":"mvdan.cc/xurls/v2","version":"v2.2.0","sum":"h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A="}]}"}}

[Trace - 11:11:58.191 AM] Sending notification 'initialized'.
Params: {}

[Trace - 11:11:58.191 AM] Sending notification 'workspace/didChangeConfiguration'.
Params: {"settings": {"gopls": {"expandWorkspaceToModule": false, "staticcheck": true, "analyses": {"unusedparams": true}, "codelenses": {"gc_details": true}, "experimentalWorkspaceModule": false}}}

[Trace - 11:11:58.192 AM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument": {"uri": "file:///home/christian/sandbox/chaudum/golang/test.go", "version": 0, "languageId": "go", "text": "package main\n\nimport {\n "fmt"\n}\n\nfunc main() {\n fmt.Println("Hello gopls!")\n}\n"}}

[Trace - 11:11:58.192 AM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Error - Sent] 11:11:58.192 AM #1 MethodNotFound

[Trace - 11:11:58.192 AM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///home/christian/sandbox/chaudum/golang","section":"gopls"}]}

[Trace - 11:11:58.192 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/02/05 11:11:58 starting work for Setting up workspace: MethodNotFound\n"}

[Error - Sent] 11:11:58.192 AM #2 MethodNotFound

[Trace - 11:11:58.192 AM] Received notification 'window/showMessage'.
Params: {"type":1,"message":"Error loading workspace folders (expected 1, got 0)\nfailed to load view for file:///home/christian/sandbox/chaudum/golang: failed to get workspace configuration from client (file:///home/christian/sandbox/chaudum/golang): MethodNotFound\n"}

[Trace - 11:11:58.193 AM] Received request 'workspace/configuration - (3)'.
Params: {"items":[{"section":"gopls"}]}

[Error - Sent] 11:11:59.737 AM #3 MethodNotFound

[Trace - 11:11:59.738 AM] Received request 'window/workDoneProgress/create - (4)'.
Params: {"token":"8674665223082153551"}

[Error - Sent] 11:11:59.740 AM #4 MethodNotFound

[Trace - 11:11:59.740 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/02/05 11:11:59 starting work for Setting up workspace: MethodNotFound\n"}

[Trace - 11:11:59.740 AM] Received request 'workspace/configuration - (5)'.
Params: {"items":[{"scopeUri":"file:///home/christian/sandbox/chaudum/golang","section":"gopls"}]}

[Error - Sent] 11:11:59.743 AM #5 MethodNotFound

[Trace - 11:11:59.743 AM] Received notification 'window/showMessage'.
Params: {"type":1,"message":"Error loading workspace folders (expected 1, got 0)\nfailed to load view for file:///home/christian/sandbox/chaudum/golang: failed to get workspace configuration from client (file:///home/christian/sandbox/chaudum/golang): MethodNotFound\n"}

[Trace - 11:12:04.995 AM] Sending notification 'textDocument/didSave'.
Params: {"textDocument": {"uri": "file:///home/christian/sandbox/chaudum/golang/test.go"}}

[Trace - 11:12:04.995 AM] Sending request 'shutdown - (2)'.
Params:

[Trace - 11:12:04.996 AM] Received response 'shutdown - (2)' in 0ms.
Result: null

[Trace - 11:12:04.996 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/02/05 11:12:04 Shutdown session\n\tshutdown_session=1\n"}

[Trace - 11:12:04.997 AM] Sending notification 'exit'.
Params:

@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 Feb 5, 2021
@gopherbot gopherbot added this to the Unreleased milestone Feb 5, 2021
@stamblerre
Copy link
Contributor

It looks like this Vim client may not support the workspace/configuration request, which is surprising because it's been a part of the protocol for a long time. I think it makes more sense to report this problem to the Vim client, as I don't think this is a gopls bug.

@chaudum
Copy link
Author

chaudum commented Feb 5, 2021

Hi @stamblerre Thanks for the quick reply. Installing the latest Neovim nightly did really solve the problem (probably because of neovim/neovim@48caf1d).

@chaudum chaudum closed this as completed Feb 5, 2021
@stamblerre stamblerre removed this from the Unreleased milestone Feb 5, 2021
@golang golang locked and limited conversation to collaborators Feb 5, 2022
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