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: doesn't work with GOPATH vendoring #36155

Closed
ian-mi opened this issue Dec 16, 2019 · 10 comments
Closed

x/tools/gopls: doesn't work with GOPATH vendoring #36155

ian-mi opened this issue Dec 16, 2019 · 10 comments

Comments

@ian-mi
Copy link

@ian-mi ian-mi commented Dec 16, 2019

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

$ go version
go version go1.12.9 linux/amd64

Does this issue reproduce with the latest release?

Yes

gopls version
golang.org/x/tools/gopls 0.2.2
    golang.org/x/tools/gopls@v0.2.2 h1:ujGisyytgY1VGcmd66wIJ9+wVAfmodXj6daHM43HRXk=

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

See logs.

What did you do?

Performed the following steps:

  1. Opened the file fake.go.
  2. Added the import github.com/google/go-cmp/cmp.
  3. Typed cmp.Diff.
  4. Saved the file.
  5. Retyped cmp.Diff.

These steps seem to reliably reproduce the issue.

What did you expect to see?

Expected to see completion results for the newly imported package before saving the file.

What did you see instead?

I saw no completion results for cmp.Diff before saving the file but did after saving.
gopls.log
lsp-trace.log

@gopherbot gopherbot added this to the Unreleased milestone Dec 16, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 16, 2019

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@stamblerre stamblerre changed the title x/tools/gopls: New import not loaded until file is saved x/tools/gopls: new import not loaded until file is saved Dec 16, 2019
@stamblerre stamblerre modified the milestones: Unreleased, gopls v1.0 Dec 16, 2019
@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Dec 17, 2019

I can't reproduce this with gopls master either in GOPATH or module mode. Can you give master a try?

@ian-mi

This comment has been minimized.

Copy link
Author

@ian-mi ian-mi commented Dec 17, 2019

Yes, I was able to reproduce the issue on master but the logs look much different.
gopls.log
lsp-trace.log

@ian-mi

This comment has been minimized.

Copy link
Author

@ian-mi ian-mi commented Dec 17, 2019

This particular project is in GOPATH mode using vendored deps. I haven't tried to reproduce the issue in module mode.

@ian-mi

This comment has been minimized.

Copy link
Author

@ian-mi ian-mi commented Dec 17, 2019

I've also seen a similar issue when creating a new file gopls won't work in that buffer until the file is saved to disk.

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Dec 17, 2019

Your logs weirdly don't mention cmp at all, but I was able to reproduce the problem by checking out knative-gcp and following the same steps.

Pretty sure this has something to do with vendoring. I get errors like

[Error - 3:46:18 PM] 2019/12/17 15:46:18 no dep handle: no metadata for github.com/google/knative-gcp/vendor/github.com/google/go-cmp/cmp
        package = github.com/google/knative-gcp/vendor/github.com/google/go-cmp/cmp

which are quite suspicious.

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Dec 17, 2019

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Dec 17, 2019

There's also some code path where we do go list on an import path, which also doesn't work; afaict you have to list the vendor path, e.g. github.com/google/knative-gcp/vendor/github.com/google/go-cmp/cmp.

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Dec 17, 2019

That is probably happening in the go/packages overlay support, which needs to augment the response with the packages that are imported only in the overlay.

Sigh.

@stamblerre stamblerre changed the title x/tools/gopls: new import not loaded until file is saved x/tools/gopls: doesn't work with GOPATH vendoring Dec 19, 2019
@heschik heschik modified the milestones: gopls/v1.0.0, gopls/v0.3.0 Jan 15, 2020
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jan 23, 2020

Change https://golang.org/cl/215904 mentions this issue: internal/lsp/cache: fix GOPATH vendoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.