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 when working in the go project (go/src) #45890

Open
hyangah opened this issue Apr 30, 2021 · 2 comments
Open

Comments

@hyangah
Copy link
Contributor

@hyangah hyangah commented Apr 30, 2021

I opened vscode from go/src directory with the experimentalWorkspaceModule feature enabled , and got this work progress notification:

Error loading workspace: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s : packages.Load error
go version devel go1.17-8e91458b19 Fri Apr 30 20:00:36 2021 +0000 darwin/amd64

gopls's version
devel go1.17-8e91458b19 Fri Apr 30 20:00:36 2021 +0000
        path    golang.org/x/tools/gopls
        mod     golang.org/x/tools/gopls        v0.6.10 h1:8Ebz8PymS2umcuCFhoz67unyJfWsipjTIrkBUF9kypg=
        dep     github.com/BurntSushi/toml      v0.3.1  h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
        dep     github.com/google/go-cmp        v0.5.4  h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
        dep     github.com/sergi/go-diff        v1.1.0  h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
        dep     golang.org/x/mod        v0.4.1  h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
        dep     golang.org/x/sync       v0.0.0-20201020160332-67f06af15bc9      h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
        dep     golang.org/x/sys        v0.0.0-20210124154548-22da62e12c0c      h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
        dep     golang.org/x/tools      v0.1.1-0.20210408155258-593413344da1    h1:B+9Jhwu5uM+kDMAkoQH6IUoIoS48VbRqwLyceNdpRK8=
        dep     golang.org/x/xerrors    v0.0.0-20200804184101-5ec99f83aff1      h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
        dep     honnef.co/go/tools      v0.1.3  h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o=
        dep     mvdan.cc/gofumpt        v0.1.1  h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
        dep     mvdan.cc/xurls/v2       v2.2.0  h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
gopls log [Trace - 17:15:10.498 PM] Sending request 'initialize - (0)'. Params: {"processId":51867,"clientInfo":{"name":"Visual Studio Code - Insiders","version":"1.56.0-insider"},"locale":"en-us","rootPath":"/Users/hakim/go_tip/go/src","rootUri":"file:///Users/hakim/go_tip/go/src","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"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]},"tagSupport":{"valueSet":[1]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSupport":{"valueSet":[1,2]}},"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]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"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]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"honorsChangeAnnotations":false},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1,"honorsChangeAnnotations":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}},"multilineTokenSupport":false,"overlappingTokenSupport":false},"linkedEditingRange":{"dynamicRegistration":true}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true},"workDoneProgress":true},"general":{"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0"}}},"initializationOptions":{"build.experimentalWorkspaceModule":true,"ui.diagnostic.staticcheck":true,"ui.semanticTokens":true,"ui.completion.experimentalPostfixCompletions":true,"allExperiments":true},"trace":"verbose","workspaceFolders":[{"uri":"file:///Users/hakim/go_tip/go/src","name":"src"}]}

[Trace - 17:15:10.500 PM] Received response 'initialize - (0)' in 1ms.
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.add_dependency","gopls.add_import","gopls.apply_fix","gopls.check_upgrades","gopls.gc_details","gopls.generate","gopls.generate_gopls_mod","gopls.go_get_package","gopls.list_known_packages","gopls.regenerate_cgo","gopls.remove_dependency","gopls.run_tests","gopls.test","gopls.tidy","gopls.toggle_gc_details","gopls.update_go_sum","gopls.upgrade_dependency","gopls.vendor","gopls.workspace_metadata"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{"path":"golang.org/x/tools/gopls","version":"v0.6.10","sum":"h1:8Ebz8PymS2umcuCFhoz67unyJfWsipjTIrkBUF9kypg=","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.1","sum":"h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY="},{"path":"golang.org/x/sync","version":"v0.0.0-20201020160332-67f06af15bc9","sum":"h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck="},{"path":"golang.org/x/sys","version":"v0.0.0-20210124154548-22da62e12c0c","sum":"h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk="},{"path":"golang.org/x/tools","version":"v0.1.1-0.20210408155258-593413344da1","sum":"h1:B+9Jhwu5uM+kDMAkoQH6IUoIoS48VbRqwLyceNdpRK8="},{"path":"golang.org/x/xerrors","version":"v0.0.0-20200804184101-5ec99f83aff1","sum":"h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE="},{"path":"honnef.co/go/tools","version":"v0.1.3","sum":"h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o="},{"path":"mvdan.cc/gofumpt","version":"v0.1.1","sum":"h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA="},{"path":"mvdan.cc/xurls/v2","version":"v2.2.0","sum":"h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A="}]}"}}

[Trace - 17:15:10.571 PM] Sending notification 'initialized'.
Params: {}

[Trace - 17:15:10.571 PM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Trace - 17:15:10.576 PM] Sending response 'window/workDoneProgress/create - (1)' in 4ms.
Result:

[Trace - 17:15:10.576 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}

[Trace - 17:15:10.576 PM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///Users/hakim/go_tip/go/src","section":"gopls"}]}

[Trace - 17:15:10.592 PM] Sending response 'workspace/configuration - (2)' in 15ms.
Result: [{"build.experimentalWorkspaceModule":true,"ui.diagnostic.staticcheck":true,"ui.semanticTokens":true,"ui.completion.experimentalPostfixCompletions":true,"allExperiments":true}]

[Trace - 17:15:10.761 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/04/30 17:15:10 go env for /Users/hakim/go_tip/go/src\n(root /Users/hakim/go_tip/go/src)\n(go version go version devel go1.17-8e91458b19 Fri Apr 30 20:00:36 2021 +0000 darwin/amd64)\n(valid build configuration = true)\n(build flags: [])\nGOINSECURE=\nGOSUMDB=sum.golang.org\nGOMODCACHE=/Users/hakim/go/pkg/mod\nGONOPROXY=\nGOCACHE=/Users/hakim/Library/Caches/go-build\nGOPROXY=https://proxy.golang.org,direct\nGOROOT=/Users/hakim/go_tip/go\nGO111MODULE=\nGOFLAGS=\nGOMOD=/Users/hakim/go_tip/go/src/go.mod\nGOPATH=/Users/hakim/go\nGOPRIVATE=\nGONOSUMDB=\n\n"}

[Info - 5:15:10 PM] 2021/04/30 17:15:10 go env for /Users/hakim/go_tip/go/src
(root /Users/hakim/go_tip/go/src)
(go version go version devel go1.17-8e91458b19 Fri Apr 30 20:00:36 2021 +0000 darwin/amd64)
(valid build configuration = true)
(build flags: [])
GOINSECURE=
GOSUMDB=sum.golang.org
GOMODCACHE=/Users/hakim/go/pkg/mod
GONOPROXY=
GOCACHE=/Users/hakim/Library/Caches/go-build
GOPROXY=https://proxy.golang.org,direct
GOROOT=/Users/hakim/go_tip/go
GO111MODULE=
GOFLAGS=
GOMOD=/Users/hakim/go_tip/go/src/go.mod
GOPATH=/Users/hakim/go
GOPRIVATE=
GONOSUMDB=

[Trace - 17:15:13.684 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/04/30 17:15:13 go/packages.Load: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\ngo build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\n\n\tsnapshot=0\n\tdirectory=/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/gopls-workspace-mod113915190\n\tquery=[builtin cmd/... std/...]\n\tpackages=0\n"}

[Trace - 17:15:13.684 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/04/30 17:15:13 initial workspace load failed: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\ngo build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\n: packages.Load error\n"}

[Error - 5:15:13 PM] 2021/04/30 17:15:13 go/packages.Load: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s

snapshot=0
directory=/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/gopls-workspace-mod113915190
query=[builtin cmd/... std/...]
packages=0

[Trace - 17:15:13.685 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/04/30 17:15:13 diagnosing go.mod: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\ngo build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\n: packages.Load error\n"}

[Trace - 17:15:13.685 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/04/30 17:15:13 diagnosing go.mod: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\ngo build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\n: packages.Load error\n"}

[Trace - 17:15:13.685 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"end","message":"Finished loading packages."}}

[Trace - 17:15:13.685 PM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{go,mod,sum}","kind":7},{"globPattern":"{/Users/hakim/go_tip/go/src/cmd}","kind":7}]}}]}

[Trace - 17:15:13.685 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/04/30 17:15:13 errors loading workspace: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\ngo build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\n: packages.Load error\n\tsnapshot=0\n\tdirectory=file:///Users/hakim/go_tip/go/src\n"}

[Trace - 17:15:13.686 PM] Received request 'window/workDoneProgress/create - (4)'.
Params: {"token":"8674665223082153551"}

[Error - 5:15:13 PM] 2021/04/30 17:15:13 initial workspace load failed: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
: packages.Load error

[Error - 5:15:13 PM] 2021/04/30 17:15:13 diagnosing go.mod: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
: packages.Load error

[Error - 5:15:13 PM] 2021/04/30 17:15:13 diagnosing go.mod: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
: packages.Load error

[Error - 5:15:13 PM] 2021/04/30 17:15:13 errors loading workspace: err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s
: packages.Load error
snapshot=0
directory=file:///Users/hakim/go_tip/go/src

[Trace - 17:15:13.691 PM] Sending response 'client/registerCapability - (3)' in 5ms.
Result:

[Trace - 17:15:13.691 PM] Sending response 'window/workDoneProgress/create - (4)' in 5ms.
Result:

[Trace - 17:15:13.692 PM] Received request 'client/registerCapability - (5)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"},{"id":"textDocument/semanticTokens","method":"textDocument/semanticTokens","registerOptions":{"legend":{"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","member","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"]},"range":true,"full":true}}]}

[Trace - 17:15:13.692 PM] Received notification '$/progress'.
Params: {"token":"8674665223082153551","value":{"kind":"begin","title":"Error loading workspace","message":"err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s : packages.Load error"}}

[Trace - 17:15:13.692 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/go_tip/go/src/cmd/go.mod","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":10}},"severity":1,"source":"go list","message":"err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\ngo build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\n: packages.Load error"}]}

[Trace - 17:15:13.692 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/go_tip/go/src/go.mod","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":10}},"severity":1,"source":"go list","message":"err: exit status 1: stderr: go build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\ngo build std/runtime/cgo: package using cgo has Go assembly file asm_amd64.s\n: packages.Load error"}]}

[Trace - 17:15:13.695 PM] Sending response 'client/registerCapability - (5)' in 3ms.
Result:

@gopherbot gopherbot added this to the Unreleased milestone Apr 30, 2021
@heschi
Copy link
Contributor

@heschi heschi commented Apr 30, 2021

You're in experimental workspace module mode. I don't think we've ever tested it with the standard library, and clearly it doesn't work. In retrospect, that's not surprising: it's not remotely possible to write replace std /path in a go.mod and get anything reasonable.

Perhaps we can easily special-case the standard library; it is valid to run go list std cmd (not std/... cmd/...) and get results that should work with the workspace module code.

@hyangah
Copy link
Contributor Author

@hyangah hyangah commented May 1, 2021

Thanks for taking a look, @heschi!
The go project repo contains multiple modules. It will be helpful if go project contributors who work on multiple modules (std, cmd..) at once can utilize multi-module repo support when using gopls. Since go command already does something special about the modules there, I think it makes sense to special case the go project.

cc @matloob to see if this is something worth discussing in his go.work proposal.

@hyangah hyangah modified the milestones: Unreleased, gopls/v1.0.0 May 6, 2021
@hyangah hyangah added Soon and removed Soon labels May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants