Skip to content

x/tools/gopls: consider to turn off buildvcs inside gopls #51999

Open
@hyangah

Description

@hyangah

gopls version

golang.org/x/tools/gopls v0.8.1
compiled with go1.18 (google-golang)

What did you do?

We have a project that has a third-party go project as its git submodule.

my_project
  +--- go.work
  +--- their_project
               +--- go.mod
               +--- main.go

go.work has only ./their_project in it.

I opened vscode from my_project , so gopls sees my_project as the workspace root.

What did you expect to see?

Working normally.

What did you see instead?

All go files in the their_project directory get errors with source go list.
gopls log:

[Trace - 23:38:54.242 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///home/hakim/projects/my_project/their_project/cmd/tester/main.go",
"diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},
"severity":1,
"source":"go list",
"message":"error obtaining VCS status: main package is in repository 
\"/home/hakim/projects/my_project/their_project\" but current directory is in repository 
\"/home/hakim/projects/my_project\"\n\tUse -buildvcs=false to disable VCS stamping."}]}

I understand this is an error message from go, and I can work around by disabling the buildvcs flag.

However, what's puzzling is, if I run go list from their_project, it runs without an error.

$ go list ./triage-party/...
error obtaining VCS status: main package is in repository "/home/hakim/projects/my_project/their_project" but current directory is in repository "/home/hakim/projects/my_project"
        Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: main package is in repository "/home/hakim/projects/my_project/their_project" but current directory is in repository "/home/hakim/projects/my_project"
        Use -buildvcs=false to disable VCS stamping.

$ cd ./triage-party; go list ./...
go list ./...
github.com/they/their_project/cmd/server
...        

I don't know what's right default behavior for the go command (this is probably a niche use case) cc @bcmills

but these confusing error messages make me think gopls disable vcs build stamping by default when running go commands.
(why does gopls have to care about build stamping?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/metadataIssues related to metadata loading in gopls

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions