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: duplicate module in workspace with experimentalWorkspaceModule #45184

Open
iamshreeram opened this issue Mar 23, 2021 · 8 comments
Open

Comments

@iamshreeram
Copy link

@iamshreeram iamshreeram commented Mar 23, 2021

Issue

I use multi-module workspace (kinda monorepo). I'm getting below error from gopls for all the modules in pkg -

found module "github.com/Shopify/sarama" twice in the workspace

I found I have different versions of sarama. But I believe that is not causing this. because, The error is pointing all the modules. I have attached the screenshot with this for more details.

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

$ go version
go version go1.15.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/sram/Library/Caches/go-build"
GOENV="/Users/sram/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/sram/ram/project/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/sram/ram/project/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"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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/sn/pw7xq23n2vj_wnq16lkgdrxh0000gn/T/go-build150007759=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

gopls settings

    "gopls": {
         "ui.documentation.hoverKind": "SynopsisDocumentation",
         "build.directoryFilters": ["-/Users/sram/ram/project/node/","-node_modules"],
         "build.experimentalWorkspaceModule": true,          
      }

What did you expect to see?

No errors or warnings.

What did you see instead?

Error that says

found module "github.com/Shopify/sarama" twice in the workspace

Below is the screenshot of error:

Screen Shot 2021-03-23 at 11 53 45 AM Screen Shot 2021-03-23 at 9 13 24 AM
@gopherbot gopherbot added this to the Unreleased milestone Mar 23, 2021
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Mar 24, 2021

Thanks for filing this issue. It looks like your Go module cache (pkg/mod/...) is in your workspace. Is that intentional? Usually I'd expect the module cache to be outside of the workspace.

Also, can you please share your gopls logs? Information on how to capture them can be found here.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v1.0.0 Mar 24, 2021
@stamblerre stamblerre changed the title x/tools/gopls: Error while loading workspace - Duplicate module in workspace x/tools/gopls: duplicate module in workspace with experimentalWorkspaceModule Mar 24, 2021
@iamshreeram
Copy link
Author

@iamshreeram iamshreeram commented Mar 25, 2021

Hi @stamblerre ,
Thanks for looking into this. Please find the attachment for the gopls logs.

Yes, pkg/mod.. is inside workspace. Do you want me to filter it out using gopls filter? I want gopls to look only at my go project directory. Is there any way to restrict it by using filters? I have created #45171 ticket is to address this issue. This issue contains my workspace structure and much more information of my setup if you want to look at it once.

Thanks!

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Mar 30, 2021

Hi @stamblerre ,
Thanks for looking into this. Please find the attachment for the gopls logs.

It looks like you need to add "go.languageServerFlags": ["-rpc.trace"] to get full verbosity logs.

Yes, pkg/mod.. is inside workspace. Do you want me to filter it out using gopls filter? I want gopls to look only at my go project directory. Is there any way to restrict it by using filters? I have created #45171 ticket is to address this issue. This issue contains my workspace structure and much more information of my setup if you want to look at it once.

Thanks!

It is pretty atypical for the module cache to be in the workspace, so I would suggest avoiding that if at all possible. It won't work with experimental workspace module mode because you will run into this exact problem that you're seeing with the duplicate modules--experimental workspace mode does not support multiple modules with the same path and different versions in the workspace. If necessary, you can configure a module cache that is outside of your GOPATH by using the GOMODCACHE environment variable.

@iamshreeram
Copy link
Author

@iamshreeram iamshreeram commented Apr 1, 2021

@stamblerre, Please find the attachment for verbose logs.

gopls-vscode-duplicate-workspace-error-logs.log

On move my module cache to different path, Would I be able to copy the content from current cache and put it in different path? Or would it have to be loaded when go get?

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 1, 2021

On move my module cache to different path, Would I be able to copy the content from current cache and put it in different path? Or would it have to be loaded when go get?

I would create an empty directory that you want to use for your new module cache, set the GOMODCACHE variable to point to that directory, and then your module cache will be populated automatically whenever you build your code or open the editor. There is no need to manually populate it.

@iamshreeram
Copy link
Author

@iamshreeram iamshreeram commented Apr 9, 2021

I have modified the GOMODCACHE as suggested. The error count has reduced. But, I still see below error. I don't see anything on gopls log.

golang-error

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 9, 2021

It looks like the example.com/hello module appears multiple times in this workspace. Do you know where this module is in your workspace / can you remove the duplicate copy? You could also use the directory filters to do this.

@iamshreeram
Copy link
Author

@iamshreeram iamshreeram commented Apr 10, 2021

Yeah, I could see that this has been used in multiple place. I fixed it. Now, I'm seeing different issue.

Below is the screenshot.

Screen Shot 2021-04-09 at 11 49 29 PM

These are from the GoKafka package. Should I replace the module name?

I have added the filter -$GOPATH/src/github.com/segmentio/kafka-go, but gopls isn't picking the filter config.

Also, I have one another issue. When I hover on any function/variable/anything, I don't see any definition. Should I enable any specific setting to enable this?

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