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: "Inconsistent vendoring detected" message pops up with every keypress #40101

Closed
bconway opened this issue Jul 7, 2020 · 4 comments
Closed

Comments

@bconway
Copy link

@bconway bconway commented Jul 7, 2020

Please answer these questions before submitting your issue. Thanks!

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.14.4 darwin/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
1.46.1
cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.14.4
  • Run go env to get the go development environment details
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/myuser/Library/Caches/go-build"
GOENV="/Users/myuser/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY="github.com/mycompany/*"
GONOSUMDB="github.com/mycompany/*"
GOOS="darwin"
GOPATH="/Users/myuser/.go:/Users/myuser/code/go"
GOPRIVATE="github.com/mycompany/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/myuser/homebrew/Cellar/go/1.14.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/myuser/homebrew/Cellar/go/1.14.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dg/vgb4f3j95md47ltbzf2s5z_80000gp/T/go-build159192540=/tmp/go-build -gno-record-gcc-switches -fno-common"

Share the Go related settings you have added/edited

{
  "breadcrumbs.enabled": false,
  "editor.formatOnSave": true,
  "editor.minimap.enabled": false,
  "editor.renderWhitespace": "boundary",
  "editor.rulers": [80],
  "editor.wordWrap": "on",
  "editor.wrappingIndent": "none",
  "explorer.confirmDelete": false,
  "explorer.confirmDragAndDrop": false,
  "extensions.ignoreRecommendations": true,
  "go.coverOnSingleTest": true,
  "go.gopath": "/Users/myuser/.go:/Users/myuser/code/go",
  "go.goroot": "/Users/myuser/homebrew/opt/go/libexec",
  "go.lintFlags": [
    "-D",
    "dupl,funlen,gochecknoglobals,gochecknoinits,gocognit,gofumpt,gomnd,nestif,testpackage,wsl",
    "--enable-all",
    "--fast"
  ],
  "go.lintTool": "golangci-lint",
  "go.testFlags": ["-v", "-count=1"],
  "go.useLanguageServer": true,
  "telemetry.enableTelemetry": false,
  "workbench.colorTheme": "Visual Studio Dark",
  "workbench.settings.enableNaturalLanguageSearch": false,
  "workbench.startupEditor": "newUntitledFile"
}

Describe the bug

Every keypress, a message pops up that says:

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

This is very unusual (and annoying), because there is nothing inconsistent about my vendoring, to my knowledge. I received no errors from any go command, and my builds all complete successfully.

I have an alias that runs the following (successfully):

go get -u ./... && go mod tidy && go mod vendor

If I limit it to the following, the results are the same:

go get -u ./... && go mod vendor

Additionally, the included GitHub URL is not helpful in determining why my vendoring is allegedly inconsistent. This is from a large(ish) project, so I don't have a sample repo to share at the moment to reproduce.

Steps to reproduce the behavior:

  1. Press a key.
  2. See the message pop up.
@bconway
Copy link
Author

@bconway bconway commented Jul 7, 2020

Addendum: Clicking the go mod vendor button that is part of the error message yields no changes.

Addendum 2: I tried wiping go.sum, vendor/, and all except the first line of go.mod (package name) and rebuilding all updates and vendor/. No change in behavior.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jul 7, 2020

@blocknonip: Can you please share your gopls logs when you see this happen and click the go mod vendor button? See https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs for details on how to do that.

I agree the link isn't particularly helpful, but unfortunately there isn't a good resource on the meaning of inconsistent vendoring that we could link instead. The pop-up is necessary because none of the gopls functionality will work when inconsistent vendoring is detected, and #39164 is tracking a future work-around for this.

@stamblerre stamblerre changed the title "Inconsistent vendoring detected" message pops up with every keypress x/tools/gopls: "Inconsistent vendoring detected" message pops up with every keypress Jul 7, 2020
@stamblerre stamblerre transferred this issue from golang/vscode-go Jul 7, 2020
@gopherbot gopherbot added the Tools label Jul 7, 2020
@stamblerre stamblerre added this to the gopls/v0.5.0 milestone Jul 7, 2020
@gopherbot gopherbot added the gopls label Jul 7, 2020
@gopherbot gopherbot modified the milestones: gopls/v0.5.0, Unreleased Jul 7, 2020
@golang golang deleted a comment from gopherbot Jul 7, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Jul 8, 2020
@ericwq
Copy link

@ericwq ericwq commented Jul 10, 2020

I fixed a similar problem. my root cause is: incorrectly install google.golang.org/protobuf@v1.25.0.
after remove it everything is ok.

Trace

  1. check with :CocInfo in vim.
  2. find some error message likes:
[Error  - 9:26:26 PM] 2020/07/10 21:26:26 initial workspace load failed: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -modfile=/var/folders/kf/t5l6dj_n4dl27jtftb6vr2z00000gn/T/go.src.236222157.mod -- ./... builtin]: exit status 1: go: inconsistent vendoring in /usr/local/go/src:
	google.golang.org/protobuf@v1.25.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory


[Error  - 9:26:26 PM] 2020/07/10 21:26:26 go/packages.Load: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -modfile=/var/folders/kf/t5l6dj_n4dl27jtftb6vr2z00000gn/T/go.src.236222157.mod -- ./... builtin]: exit status 1: go: inconsistent vendoring in /usr/local/go/src:
	google.golang.org/protobuf@v1.25.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory

	snapshot=0
	directory=/usr/local/go/src
	query=[./... builtin]
	packages=0
  1. my big guess is the installation of google.golang.org/protobuf. before install it, everything is ok

Action

  • remove the google.golang.org/protobuf from $GOPATH/pkg directory
  • run go mod tidy in /usr/local/go/src directory.
  • open .go file with vim, everything is ok.

Root Cause

in https://developers.google.com/protocol-buffers/docs/gotutorial. when I follow the instruction, get the following result

go install google.golang.org/protobuf/cmd/protoc-gen-go        
can't load package: cannot find module providing package google.golang.org/protobuf/cmd/protoc-gen-go: working directory is not part of a module

then I tried with

%go get google.golang.org/protobuf/cmd/protoc-gen-go

no permission, another try

%sudo go get google.golang.org/protobuf/cmd/protoc-gen-go

Another finding

although I install gopls 0.4.3, still find there is a gopls v0.4.1 running (also though the CoCInfo log). I finally find it in the following directory:

%cd .config/coc/extensions/coc-go-data/bin/gopls
%./gopls version
golang.org/x/tools/gopls 0.4.1
    golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=

then I will consider upgrade coc release.

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 11, 2020

Change https://golang.org/cl/241984 mentions this issue: internal/lsp/source: add Vendor to list of supported commands

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
4 participants
You can’t perform that action at this time.