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: Language server doesn't work with git worktree #56736

Closed
njiang747 opened this issue Nov 14, 2022 · 5 comments
Closed

x/tools/gopls: Language server doesn't work with git worktree #56736

njiang747 opened this issue Nov 14, 2022 · 5 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@njiang747
Copy link

gopls version

golang.org/x/tools/gopls v0.10.1
    golang.org/x/tools/gopls@v0.10.1 h1:JoHe17pdZ8Vsa24/GUO8iTVTKPh0EOBiWpPop7XJybI=

go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myuser/.cache/go-build"
GOENV="/home/myuser/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/myuser/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myuser/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myuser/.cache/bazel/_bazel_myuser/debf5153b5ca4c6e23786ac22d82a8f4/external/go_sdk"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myuser/.cache/bazel/_bazel_myuser/debf5153b5ca4c6e23786ac22d82a8f4/external/go_sdk/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myuser/src/myworktree/go.mod"
GOWORK=""
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1955821808=/tmp/go-build -gno-record-gcc-switches"

What did you do?

This problem is occurring for me using VSCode's go extension but I believe the issue is in the gopls language server (since I see error logs in the gopls (server) outputs).

  • Language server seems to work without issue in my cloned repo
  • Language server does not work in a worktree of the same repo on the same commit with same VSCode version, extension version, go version, and gopls version
  • The logs in the worktree (but not the main clone) have this error (file path anonymized):
[Error - 10:26:22 PM] 2022/11/14 22:26:22 failed to compute document links: no packages
	URI=file:///home/myuser/src/myworktree/path/to/file.go

What did you expect to see?

The gopls server working in both the main clone directory and the worktree directory

What did you see instead?

The gopls server only works in the main clone directory.

Editor and settings

VSCode version 1.73.1
VSCode go extension version v0.36.0

Logs

[Error - 11:06:50 PM] 2022/11/14 23:06:50 go/packages.Load #2
	snapshot=1
	directory=/home/myuser/src/myworkspace
	query=[file=/home/myuser/src/myworkspace/path/to/file.go]
	packages=0

[Error - 11:06:50 PM] Request textDocument/codeAction failed.
  Message: no packages
  Code: 0
@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 Nov 14, 2022
@gopherbot gopherbot added this to the Unreleased milestone Nov 14, 2022
@hyangah
Copy link
Contributor

hyangah commented Nov 15, 2022

@njiang747 Is it possible to share a repro case with an open source project and its gopls log? I use git worktree as part of my daily dev work but didn't notice an issue, so I think there must be something more than use of git worktree to trigger the issue. Is the uri that appeared in your log a valid URI?

@njiang747
Copy link
Author

I can try to reproduce using an open source project but it may be difficult since my current set up uses a dev container specifically built for my repository.

It is good to know that this isn't an inherent issue with gopls and git worktrees though.

The URI is valid, I have tested the same setup in my main clone on the same commit as my worktree (with the same files open in VSCode) and the logs are similar except the package load completes successfully.

@suzmue suzmue added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 17, 2022
@suzmue suzmue modified the milestones: Unreleased, gopls/later Nov 17, 2022
@suzmue
Copy link
Contributor

suzmue commented Nov 17, 2022

@njiang747 If you are able to reproduce and capture a trace, please update this issue so we can diagnose the issue. Thank you!

@suzmue suzmue added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 17, 2022
@njiang747
Copy link
Author

Hm I just tested with https://github.com/oklog/oklog both directly on my machine and within my dev container and wasn't able to reproduce the issue (gopls language server worked on both the main clone and a worktree).

This suggests the issue is likely due to some setup issue with my repo, I will look into this. Good to know that it should work.

@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Dec 17, 2022
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Jan 17, 2024
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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants