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: updates to go.sum needed, disabled by -mod=readonly with experimentalWorkspaceModule #46061

Open
cvvz opened this issue May 9, 2021 · 12 comments
Labels
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.
Milestone

Comments

@cvvz
Copy link

cvvz commented May 9, 2021

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

$ go version
go1.15.7 darwin/amd64
VSCode Go extension v0.24.2
gopls v0.6.11

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/chenweizhi/Library/Caches/go-build"
GOENV="/Users/chenweizhi/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/chenweizhi/go/pkg/mod"
GONOPROXY="*.sankuai.com,*.dianpingoa.com"
GONOSUMDB="*.sankuai.com,*.dianpingoa.com"
GOOS="darwin"
GOPATH="/Users/chenweizhi/go"
GOPRIVATE="*.sankuai.com,*.dianpingoa.com"
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/chenweizhi/workspace/blade/blade-operator/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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ky/6_7vdv752_51h7vsm1ttmzvr0000gn/T/go-build362859145=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

The issue I encountered may be the same as #44097.
VSCode settings for gopls:

"gopls": {
        "build.experimentalWorkspaceModule": true,
        "build.expandWorkspaceToModule": true
    }

There are 2 go modules in my project, and VS Code prompt that go.sum is out of sync with go.mod. Please update it by applying the quick fix., but I can't fix it unless I delete one of the them.

What did you expect to see?

Figure it out and fix this problem in a graceful way.

@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 May 9, 2021
@gopherbot gopherbot added this to the Unreleased milestone May 9, 2021
@cvvz
Copy link
Author

cvvz commented May 9, 2021

Logs of gopls(server) with -rpc.trace

[Trace - 14:43:49.478 PM] Sending request 'textDocument/hover - (16)'.
Params: {"textDocument":{"uri":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"},"position":{"line":4,"character":33}}


[Trace - 14:43:49.478 PM] Received response 'textDocument/hover - (16)' in 0ms.
Result: null


[Trace - 14:43:49.632 PM] Sending request 'textDocument/codeAction - (17)'.
Params: {"textDocument":{"uri":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"},"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":39}},"context":{"diagnostics":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":39}},"message":"go.sum is out of sync with go.mod. Please update it by applying the quick fix.","severity":1,"source":"go list"}],"only":["quickfix"]}}


[Trace - 14:43:49.632 PM] Received response 'textDocument/codeAction - (17)' in 0ms.
Result: [{"title":"Run go mod tidy","kind":"quickfix","diagnostics":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":39}},"severity":1,"source":"go list","message":"go.sum is out of sync with go.mod. Please update it by applying the quick fix."}],"edit":{},"command":{"title":"Run go mod tidy","command":"gopls.tidy","arguments":[{"URIs":["file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/hack/tools/go.mod"]}]}},{"title":"Update go.sum","kind":"quickfix","diagnostics":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":39}},"severity":1,"source":"go list","message":"go.sum is out of sync with go.mod. Please update it by applying the quick fix."}],"edit":{},"command":{"title":"Update go.sum","command":"gopls.update_go_sum","arguments":[{"URIs":["file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/hack/tools/go.mod"]}]}}]


[Trace - 14:43:49.632 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/05/09 14:43:49 diagnosing go.mod: err: exit status 1: stderr: warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-cluster\nwarning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-operator\nwarning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/manifests/gke\nwarning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-cluster\nwarning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-operator\nwarning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/manifests/gke\ngo: updates to go.sum needed, disabled by -mod=readonly\n: packages.Load error\n"}


[Error - 2:43:49 PM] 2021/05/09 14:43:49 diagnosing go.mod: err: exit status 1: stderr: warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-cluster
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-operator
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/manifests/gke
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-cluster
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-operator
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/manifests/gke
go: updates to go.sum needed, disabled by -mod=readonly
: packages.Load error

[Trace - 14:43:52.084 PM] Sending request 'textDocument/codeLens - (18)'.
Params: {"textDocument":{"uri":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"}}


[Trace - 14:43:52.084 PM] Received response 'textDocument/codeLens - (18)' in 0ms.
Result: [{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":39}},"command":{"title":"Run go mod tidy","command":"gopls.tidy","arguments":[{"URIs":["file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"]}]}},{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":39}},"command":{"title":"Create vendor directory","command":"gopls.vendor","arguments":[{"URI":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"}]}},{"range":{"start":{"line":8,"character":0},"end":{"line":99,"character":1}},"command":{"title":"Check for upgrades","command":"gopls.check_upgrades","arguments":[{"URI":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","Modules":["github.com/Azure/go-autorest/autorest/mocks","github.com/BurntSushi/toml","github.com/MakeNowJust/heredoc","github.com/Masterminds/semver","github.com/Microsoft/go-winio","github.com/NYTimes/gziphandler","github.com/aws/aws-sdk-go","github.com/chai2010/gettext-go","github.com/codahale/hdrhistogram","github.com/coreos/etcd","github.com/docker/docker","github.com/docker/go-connections","github.com/docker/spdystream","github.com/dsnet/compress","github.com/dustin/go-humanize","github.com/elazarl/goproxy","github.com/elazarl/goproxy/ext","github.com/emicklei/go-restful","github.com/fatih/color","github.com/ghodss/yaml","github.com/go-openapi/spec","github.com/go-sql-driver/mysql","github.com/gogo/protobuf","github.com/golang/groupcache","github.com/golang/snappy","github.com/google/go-cmp","github.com/google/gofuzz","github.com/gophercloud/gophercloud","github.com/gregjones/httpcache","github.com/grpc-ecosystem/go-grpc-middleware","github.com/grpc-ecosystem/grpc-gateway","github.com/imdario/mergo","github.com/juju/errors","github.com/juju/loggo","github.com/juju/testing","github.com/mholt/archiver","github.com/minio/minio-go/v6","github.com/mohae/deepcopy","github.com/nwaples/rardecode","github.com/onsi/ginkgo","github.com/onsi/gomega","github.com/openshift/generic-admission-server","github.com/opentracing/opentracing-go","github.com/pierrec/lz4","github.com/pingcap/advanced-statefulset/client","github.com/pingcap/check","github.com/pingcap/errors","github.com/pingcap/kvproto","github.com/pingcap/tidb","github.com/prometheus/client_golang","github.com/prometheus/client_model","github.com/prometheus/common","github.com/prometheus/prom2json","github.com/prometheus/prometheus","github.com/robfig/cron","github.com/sirupsen/logrus","github.com/soheilhy/cmux","github.com/spf13/cobra","github.com/spf13/pflag","github.com/tikv/pd","github.com/tmc/grpc-websocket-proxy","github.com/uber-go/atomic","github.com/uber/jaeger-client-go","github.com/uber/jaeger-lib","github.com/xi2/xz","github.com/xiang90/probing","github.com/yisaer/crd-validation","gocloud.dev","golang.org/x/sync","golang.org/x/time","gomodules.xyz/jsonpatch/v2","gopkg.in/mgo.v2","gopkg.in/yaml.v2","k8s.io/api","k8s.io/apiextensions-apiserver","k8s.io/apimachinery","k8s.io/apiserver","k8s.io/cli-runtime","k8s.io/client-go","k8s.io/code-generator","k8s.io/component-base","k8s.io/klog","k8s.io/kube-aggregator","k8s.io/kube-openapi","k8s.io/kubectl","k8s.io/kubernetes","k8s.io/utils","sigs.k8s.io/apiserver-builder-alpha/cmd","sigs.k8s.io/controller-runtime","sigs.k8s.io/yaml"]}]}},{"range":{"start":{"line":8,"character":0},"end":{"line":99,"character":1}},"command":{"title":"Upgrade transitive dependencies","command":"gopls.upgrade_dependency","arguments":[{"URI":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","GoCmdArgs":["-d","-u","-t","./..."],"AddRequire":false}]}},{"range":{"start":{"line":8,"character":0},"end":{"line":99,"character":1}},"command":{"title":"Upgrade direct dependencies","command":"gopls.upgrade_dependency","arguments":[{"URI":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","GoCmdArgs":["-d","github.com/Azure/go-autorest/autorest/mocks","github.com/BurntSushi/toml","github.com/MakeNowJust/heredoc","github.com/Masterminds/semver","github.com/Microsoft/go-winio","github.com/NYTimes/gziphandler","github.com/aws/aws-sdk-go","github.com/chai2010/gettext-go","github.com/codahale/hdrhistogram","github.com/coreos/etcd","github.com/docker/docker","github.com/docker/go-connections","github.com/docker/spdystream","github.com/dsnet/compress","github.com/dustin/go-humanize","github.com/elazarl/goproxy","github.com/elazarl/goproxy/ext","github.com/emicklei/go-restful","github.com/fatih/color","github.com/ghodss/yaml","github.com/go-openapi/spec","github.com/go-sql-driver/mysql","github.com/gogo/protobuf","github.com/golang/groupcache","github.com/golang/snappy","github.com/google/go-cmp","github.com/google/gofuzz","github.com/gophercloud/gophercloud","github.com/gregjones/httpcache","github.com/grpc-ecosystem/go-grpc-middleware","github.com/grpc-ecosystem/grpc-gateway","github.com/imdario/mergo","github.com/juju/errors","github.com/juju/loggo","github.com/juju/testing","github.com/mholt/archiver","github.com/minio/minio-go/v6","github.com/mohae/deepcopy","github.com/nwaples/rardecode","github.com/onsi/ginkgo","github.com/onsi/gomega","github.com/openshift/generic-admission-server","github.com/opentracing/opentracing-go","github.com/pierrec/lz4","github.com/pingcap/advanced-statefulset/client","github.com/pingcap/check","github.com/pingcap/errors","github.com/pingcap/kvproto","github.com/pingcap/tidb","github.com/prometheus/client_golang","github.com/prometheus/client_model","github.com/prometheus/common","github.com/prometheus/prom2json","github.com/prometheus/prometheus","github.com/robfig/cron","github.com/sirupsen/logrus","github.com/soheilhy/cmux","github.com/spf13/cobra","github.com/spf13/pflag","github.com/tikv/pd","github.com/tmc/grpc-websocket-proxy","github.com/uber-go/atomic","github.com/uber/jaeger-client-go","github.com/uber/jaeger-lib","github.com/xi2/xz","github.com/xiang90/probing","github.com/yisaer/crd-validation","gocloud.dev","golang.org/x/sync","golang.org/x/time","gomodules.xyz/jsonpatch/v2","gopkg.in/mgo.v2","gopkg.in/yaml.v2","k8s.io/api","k8s.io/apiextensions-apiserver","k8s.io/apimachinery","k8s.io/apiserver","k8s.io/cli-runtime","k8s.io/client-go","k8s.io/code-generator","k8s.io/component-base","k8s.io/klog","k8s.io/kube-aggregator","k8s.io/kube-openapi","k8s.io/kubectl","k8s.io/kubernetes","k8s.io/utils","sigs.k8s.io/apiserver-builder-alpha/cmd","sigs.k8s.io/controller-runtime","sigs.k8s.io/yaml"],"AddRequire":false}]}}]


[Trace - 14:43:54.868 PM] Sending request 'workspace/executeCommand - (19)'.
Params: {"command":"gopls.update_go_sum","arguments":[{"URIs":["file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/hack/tools/go.mod"]}]}


[Trace - 14:43:54.869 PM] Received request 'window/workDoneProgress/create - (6)'.
Params: {"token":"6129484611666145821"}


[Trace - 14:43:54.869 PM] Sending response 'window/workDoneProgress/create - (6)' in 0ms.
Result: 


[Trace - 14:43:54.869 PM] Received notification '$/progress'.
Params: {"token":"6129484611666145821","value":{"kind":"begin","title":"Updating go.sum","cancellable":true,"message":"Running..."}}


[Trace - 14:43:55.116 PM] Sending request 'textDocument/codeLens - (20)'.
Params: {"textDocument":{"uri":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"}}


[Trace - 14:43:56.212 PM] Received notification '$/progress'.
Params: {"token":"6129484611666145821","value":{"kind":"end","message":"completed"}}


[Trace - 14:43:56.212 PM] Received response 'workspace/executeCommand - (19)' in 1344ms.
Result: null


[Trace - 14:43:56.213 PM] Received response 'textDocument/codeLens - (20)' in 1096ms.
Result: [{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":39}},"command":{"title":"Run go mod tidy","command":"gopls.tidy","arguments":[{"URIs":["file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"]}]}},{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":39}},"command":{"title":"Create vendor directory","command":"gopls.vendor","arguments":[{"URI":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"}]}},{"range":{"start":{"line":8,"character":0},"end":{"line":99,"character":1}},"command":{"title":"Check for upgrades","command":"gopls.check_upgrades","arguments":[{"URI":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","Modules":["github.com/Azure/go-autorest/autorest/mocks","github.com/BurntSushi/toml","github.com/MakeNowJust/heredoc","github.com/Masterminds/semver","github.com/Microsoft/go-winio","github.com/NYTimes/gziphandler","github.com/aws/aws-sdk-go","github.com/chai2010/gettext-go","github.com/codahale/hdrhistogram","github.com/coreos/etcd","github.com/docker/docker","github.com/docker/go-connections","github.com/docker/spdystream","github.com/dsnet/compress","github.com/dustin/go-humanize","github.com/elazarl/goproxy","github.com/elazarl/goproxy/ext","github.com/emicklei/go-restful","github.com/fatih/color","github.com/ghodss/yaml","github.com/go-openapi/spec","github.com/go-sql-driver/mysql","github.com/gogo/protobuf","github.com/golang/groupcache","github.com/golang/snappy","github.com/google/go-cmp","github.com/google/gofuzz","github.com/gophercloud/gophercloud","github.com/gregjones/httpcache","github.com/grpc-ecosystem/go-grpc-middleware","github.com/grpc-ecosystem/grpc-gateway","github.com/imdario/mergo","github.com/juju/errors","github.com/juju/loggo","github.com/juju/testing","github.com/mholt/archiver","github.com/minio/minio-go/v6","github.com/mohae/deepcopy","github.com/nwaples/rardecode","github.com/onsi/ginkgo","github.com/onsi/gomega","github.com/openshift/generic-admission-server","github.com/opentracing/opentracing-go","github.com/pierrec/lz4","github.com/pingcap/advanced-statefulset/client","github.com/pingcap/check","github.com/pingcap/errors","github.com/pingcap/kvproto","github.com/pingcap/tidb","github.com/prometheus/client_golang","github.com/prometheus/client_model","github.com/prometheus/common","github.com/prometheus/prom2json","github.com/prometheus/prometheus","github.com/robfig/cron","github.com/sirupsen/logrus","github.com/soheilhy/cmux","github.com/spf13/cobra","github.com/spf13/pflag","github.com/tikv/pd","github.com/tmc/grpc-websocket-proxy","github.com/uber-go/atomic","github.com/uber/jaeger-client-go","github.com/uber/jaeger-lib","github.com/xi2/xz","github.com/xiang90/probing","github.com/yisaer/crd-validation","gocloud.dev","golang.org/x/sync","golang.org/x/time","gomodules.xyz/jsonpatch/v2","gopkg.in/mgo.v2","gopkg.in/yaml.v2","k8s.io/api","k8s.io/apiextensions-apiserver","k8s.io/apimachinery","k8s.io/apiserver","k8s.io/cli-runtime","k8s.io/client-go","k8s.io/code-generator","k8s.io/component-base","k8s.io/klog","k8s.io/kube-aggregator","k8s.io/kube-openapi","k8s.io/kubectl","k8s.io/kubernetes","k8s.io/utils","sigs.k8s.io/apiserver-builder-alpha/cmd","sigs.k8s.io/controller-runtime","sigs.k8s.io/yaml"]}]}},{"range":{"start":{"line":8,"character":0},"end":{"line":99,"character":1}},"command":{"title":"Upgrade transitive dependencies","command":"gopls.upgrade_dependency","arguments":[{"URI":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","GoCmdArgs":["-d","-u","-t","./..."],"AddRequire":false}]}},{"range":{"start":{"line":8,"character":0},"end":{"line":99,"character":1}},"command":{"title":"Upgrade direct dependencies","command":"gopls.upgrade_dependency","arguments":[{"URI":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod","GoCmdArgs":["-d","github.com/Azure/go-autorest/autorest/mocks","github.com/BurntSushi/toml","github.com/MakeNowJust/heredoc","github.com/Masterminds/semver","github.com/Microsoft/go-winio","github.com/NYTimes/gziphandler","github.com/aws/aws-sdk-go","github.com/chai2010/gettext-go","github.com/codahale/hdrhistogram","github.com/coreos/etcd","github.com/docker/docker","github.com/docker/go-connections","github.com/docker/spdystream","github.com/dsnet/compress","github.com/dustin/go-humanize","github.com/elazarl/goproxy","github.com/elazarl/goproxy/ext","github.com/emicklei/go-restful","github.com/fatih/color","github.com/ghodss/yaml","github.com/go-openapi/spec","github.com/go-sql-driver/mysql","github.com/gogo/protobuf","github.com/golang/groupcache","github.com/golang/snappy","github.com/google/go-cmp","github.com/google/gofuzz","github.com/gophercloud/gophercloud","github.com/gregjones/httpcache","github.com/grpc-ecosystem/go-grpc-middleware","github.com/grpc-ecosystem/grpc-gateway","github.com/imdario/mergo","github.com/juju/errors","github.com/juju/loggo","github.com/juju/testing","github.com/mholt/archiver","github.com/minio/minio-go/v6","github.com/mohae/deepcopy","github.com/nwaples/rardecode","github.com/onsi/ginkgo","github.com/onsi/gomega","github.com/openshift/generic-admission-server","github.com/opentracing/opentracing-go","github.com/pierrec/lz4","github.com/pingcap/advanced-statefulset/client","github.com/pingcap/check","github.com/pingcap/errors","github.com/pingcap/kvproto","github.com/pingcap/tidb","github.com/prometheus/client_golang","github.com/prometheus/client_model","github.com/prometheus/common","github.com/prometheus/prom2json","github.com/prometheus/prometheus","github.com/robfig/cron","github.com/sirupsen/logrus","github.com/soheilhy/cmux","github.com/spf13/cobra","github.com/spf13/pflag","github.com/tikv/pd","github.com/tmc/grpc-websocket-proxy","github.com/uber-go/atomic","github.com/uber/jaeger-client-go","github.com/uber/jaeger-lib","github.com/xi2/xz","github.com/xiang90/probing","github.com/yisaer/crd-validation","gocloud.dev","golang.org/x/sync","golang.org/x/time","gomodules.xyz/jsonpatch/v2","gopkg.in/mgo.v2","gopkg.in/yaml.v2","k8s.io/api","k8s.io/apiextensions-apiserver","k8s.io/apimachinery","k8s.io/apiserver","k8s.io/cli-runtime","k8s.io/client-go","k8s.io/code-generator","k8s.io/component-base","k8s.io/klog","k8s.io/kube-aggregator","k8s.io/kube-openapi","k8s.io/kubectl","k8s.io/kubernetes","k8s.io/utils","sigs.k8s.io/apiserver-builder-alpha/cmd","sigs.k8s.io/controller-runtime","sigs.k8s.io/yaml"],"AddRequire":false}]}}]


[Trace - 14:43:56.216 PM] Sending request 'textDocument/codeAction - (21)'.
Params: {"textDocument":{"uri":"file:///Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/go.mod"},"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"context":{"diagnostics":[]}}


[Trace - 14:43:56.216 PM] Received response 'textDocument/codeAction - (21)' in 0ms.
Result: null

@findleyr
Copy link
Contributor

findleyr commented May 9, 2021

Thank you for the report. I agree that this is probably a dupe of #44097, but the resolution there was to improve the quick fix. Perhaps it needs more refinement, so let's keep this open.

but I can't fix it unless I delete one of the them.

It should be possible to fix this error without deleting one of the modules. Do you get a quick fix on the module directive of either go.mod file; if so, does running it resolve the error? Does running go mod tidy in both modules resolve the error?

@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 9, 2021
@findleyr findleyr modified the milestones: Unreleased, gopls/unplanned May 9, 2021
@cvvz
Copy link
Author

cvvz commented May 10, 2021

Do you get a quick fix on the module directive of either go.mod file; if so, does running it resolve the error? Does running go mod tidy in both modules resolve the error?

I do see a quick fix prompt in go.mod, which indicates me to Update go.sum or Run go mod tidy to fix. But they doesn't work. Both meet the error below:

Error loading workspace: err: exit status 1: stderr: 
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-cluster 
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-operator
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/manifests/gke 
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-cluster 
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/charts/tidb-operator 
warning: ignoring symlink /Users/chenweizhi/go/src/github.com/pingcap/tidb-operator/deploy/gcp/manifests/gke 
go: updates to go.sum needed, disabled by -mod=readonly : packages.Load error

@findleyr
Copy link
Contributor

findleyr commented May 10, 2021

I do see a quick fix prompt in go.mod, which indicates me to Update go.sum or Run go mod tidy to fix. But they doesn't work. Both meet the error below:

For what it's worth, that's not the error from the tidy command. The code lenses to fix the error should still work. I see from your logs that you ran the gopls.update_go_sum command, and that it didn't generate any edits. This does indeed look like a bug. We'll try to reproduce and fix, but this code is likely to change significantly soon anyway, with various proposals to support multi-module workspaces from the go command.

For completeness, did you try running the Run go mod tidy lens as well?

And what about tidying your modules manually from the command line (i.e. running go mod tidy from each module). Does that fix your workspace?

@cvvz
Copy link
Author

cvvz commented May 11, 2021

For completeness, did you try running the Run go mod tidy lens as well?

Yep, I tried but didn't work.

And what about tidying your modules manually from the command line (i.e. running go mod tidy from each module). Does that fix your workspace?

Also didn't work.

This does indeed look like a bug. We'll try to reproduce and fix, but this code is likely to change significantly soon anyway, with various proposals to support multi-module workspaces from the go command.

I really look forward to it! Currently, this bug can be reproduced in any project including mutiple go modules, such as Kubernetes.

@stamblerre
Copy link
Contributor

stamblerre commented May 11, 2021

I was able to reproduce this using the repository in the logs above (it is public): https://github.com/pingcap/tidb-operator. The go.mod file has a lot of replace directives, and it's possible we made a mistake in generating the gopls.mod or something conflicts with the other go.mod file: https://github.com/pingcap/tidb-operator/blob/master/hack/tools/go.mod.

@stamblerre stamblerre self-assigned this May 11, 2021
@stamblerre
Copy link
Contributor

stamblerre commented Jun 29, 2021

I've spent some time investigating this and haven't fully understood it yet. I've been running some go list commands from the "workspace directory" to understand what could be going wrong. See https://gist.github.com/stamblerre/35fbb9653fba64c872e79f7ace8ef717. I would guess that we are making some mistake when generating the go.sum file, but I can't understand what it is.

@stamblerre
Copy link
Contributor

stamblerre commented Jun 29, 2021

A good next step would be to reproduce this with the go.work proposal. Let's revisit this issue if that proposal is accepted--unassigning myself for now.

@stamblerre stamblerre removed their assignment Jun 29, 2021
@stamblerre stamblerre added this to To Do in gopls on-deck Jul 15, 2021
@findleyr
Copy link
Contributor

findleyr commented May 10, 2022

I would expect this to be resolved now when using go.work.

@strugglehonor
Copy link

strugglehonor commented Jun 8, 2022

how to fix it? I have same problem

@findleyr
Copy link
Contributor

findleyr commented Jun 8, 2022

@strugglehonor are you using experimentalWorkspaceModule? Can you please disable it and try using a go.work file with go 1.18, following the guide here?
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md#go-workspaces-go-118

@cvvz
Copy link
Author

cvvz commented Jun 10, 2022

@strugglehonor @findleyr go.work is almost the perfect solution for multiple modules and I've used it with gopls and VSCode for about 1 month, although sometimes packages with different version may conflict which is acceptable for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
No open projects
Development

No branches or pull requests

5 participants