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: 0.7.4 fails to handle vendor dir when experimentalWorkspaceModule is enabled #50214

Open
islishude opened this issue Dec 16, 2021 · 5 comments

Comments

@islishude
Copy link

@islishude islishude commented Dec 16, 2021

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

$ go version
go version go1.17.5 darwin/amd64

Does this issue reproduce with the latest release?

yes, I use gopls 0.7.4, and 0.7.3 works fine

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

go env Output
$ go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/lishude/Library/Caches/go-build"
GOENV="/Users/lishude/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/lishude/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/lishude/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/lishude/project/coding/gopls-vendor-bug/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6g/lnymwz651hg5mmplm29_4scm0000gn/T/go-build2470115460=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

mkdir app
cd $_
go mod init

create main.go

package main

import "golang.org/x/crypto/blake2b"

func main() {
	blake2b.New()
}
go mod tidy && go mod vendor

What did you expect to see?

no errors

What did you see instead?

vscode reports this error

Inconsistent vendoring detected. Please re-run "go mod vendor".
See https://github.com/golang/go/issues/39164 for more detail on this issue.
@hyangah
Copy link
Contributor

@hyangah hyangah commented Dec 16, 2021

Thanks for the report. @islishude
Can you please share your editor settings (i.e. gopls settings) or gopls trace?
I could reproduce this issue with "build.experimentalWorkspaceModule": true and want to double check if it's the same reproducer.

cc @findleyr

@hyangah hyangah changed the title gopls: 0.7.4 doesn't work with go vendor x/tools/gopls: 0.7.4 doesn't work with go vendor Dec 16, 2021
@hyangah hyangah added this to the gopls/on-deck milestone Dec 16, 2021
@islishude
Copy link
Author

@islishude islishude commented Dec 16, 2021

  "gopls": {
    "usePlaceholders": true,
    "completeUnimported": true,
    "deepCompletion": true,
    "hoverKind": "FullDocumentation",
    "staticcheck": false,
    "experimentalWorkspaceModule": true
  },

@islishude
Copy link
Author

@islishude islishude commented Dec 16, 2021

set experimentalWorkspaceModule to false, it works!

@hyangah hyangah changed the title x/tools/gopls: 0.7.4 doesn't work with go vendor x/tools/gopls: 0.7.4 fails to handle vendor dir when experimentalWorkspaceModule is enabled Dec 16, 2021
@hyangah hyangah removed this from the gopls/on-deck milestone Dec 16, 2021
@hyangah hyangah added this to the gopls/v0.7.5 milestone Dec 16, 2021
@findleyr
Copy link
Contributor

@findleyr findleyr commented Dec 28, 2021

It sounds like this bug might be biting several users: the likely scenario is that a fix for go directive resolution in the multi-module go.mod file (https://golang.org/cl/365737) actually broke this workflow (because now we're subject to new vendoring semantics).

I'll see if it is easy to fix this for the next gopls release, though it may be a better use of time to focus on go.work support, which shouldn't have this problem.

@findleyr findleyr removed this from the gopls/v0.7.5 milestone Jan 4, 2022
@findleyr findleyr added this to the gopls/v0.8.0 milestone Jan 4, 2022
@alexzielenski
Copy link

@alexzielenski alexzielenski commented Jan 21, 2022

I'm also finding related behavior in the kubernetes repository using workspace mode. Unless I run go mod vendor), gopls shows this error. I would like to avoid having to do that, since kubernetes symlinks source from staging into vendor, so running go mod vendor is unnecessary to build and destroys the symlinks.

Upon reading this issue, I disabled experimentalWorkspaceModule and suddenly gopls now accepted kubernetes' quirk of symlinking vendor modules from a staging folder without me running go mod vendor. No more spurious error messages. I imagine this only works for me because I am using a vscode workspace which excludes nested modules.

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
5 participants