Skip to content

x/tools/gopls: Error loading workspace: go: updates to go.mod needed, disabled by -mod=readonly : packages.Load error #44085

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

Closed
andig opened this issue Feb 3, 2021 · 10 comments
Labels
FrozenDueToAge 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@andig
Copy link
Contributor

andig commented Feb 3, 2021

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

$ go version
go version go1.15.7 darwin/amd64

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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andig/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.7/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/evcc/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/73/89ycv7qn51j4kbm04jsz9b840000gn/T/go-build649292854=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Load workspace, modules used. One go.mod created for quick testing is this:

module foo

go 1.15

require (
        github.com/PuerkitoBio/goquery v1.6.1
        github.com/andig/evcc v0.0.0-20210201204949-46d227b92b42 // indirect
        github.com/jsgoecke/tesla v0.0.0-20200530171421-e02ebd220e5a
        github.com/smartystreets/goconvey v1.6.4
        github.com/uhthomas/tesla v0.0.0-20210202211959-8f97ef33b7b3 // indirect
        golang.org/x/oauth2 v0.0.0-20210201163806-010130855d6c
)

What did you expect to see?

No gopls error and an error message that can be diagnosed and re-tried on command line.

What did you see instead?

Error loading workspace: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin foo/...]: exit status 1: go: updates to go.mod needed, disabled by -mod=readonly : packages.Load error

It would also be great if gopls didn't fail as it should not update the go.mod.

I'm also unsure how to invoke the command to reproduce the error, the notation in the gopls log might be clearer:

go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin foo/...]
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Feb 3, 2021
@seankhliao seankhliao changed the title gopls: Error loading workspace: go: updates to go.mod needed, disabled by -mod=readonly : packages.Load error x/tools/gopls: Error loading workspace: go: updates to go.mod needed, disabled by -mod=readonly : packages.Load error Feb 3, 2021
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Feb 3, 2021
@gopherbot gopherbot added this to the Unreleased milestone Feb 3, 2021
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 3, 2021
@stamblerre
Copy link
Contributor

If you navigate to the Problems pane in VS Code or open your go.mod file, you should see diagnostics highlighting the error, along with suggested fixes. Clicking on those suggested fixes should resolve the problem. Does that work for you?

We have also been working on improving the error message, and I believe that will be addressed in an upcoming release.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/unplanned Feb 3, 2021
@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 3, 2021
@samstride
Copy link

samstride commented Feb 4, 2021

@stamblerre , I am seeing this error after upgrading to gopls v0.6.5.

My VS code settings for gopls are:

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

When I click on the light bulb and try to apply the suggested fix - which is to run go mod tidy and update go.sum nothing seems to happen.

I have run go mod tidy manually but nothing seems to happen.

The Error loading workspace message at the very bottom has a spinning icon next to it.

Screen Shot 2021-02-04 at 12 58 55 PM

@stamblerre
Copy link
Contributor

stamblerre commented Feb 4, 2021

@samstride: Do you minding file a new issue so that we can discuss this separately? Also, please attach a gopls log to the issue. Information on how to capture logs can be found here.

@samstride
Copy link

samstride commented Feb 4, 2021

@stamblerre , sure can do, however I am facing the exact same error message so do you want me to use a specific title for the new issue?

@stamblerre
Copy link
Contributor

Any title is fine--you can also use the same title as this issue.

@andig
Copy link
Contributor Author

andig commented Feb 4, 2021

If you navigate to the Problems pane in VS Code or open your go.mod file, you should see diagnostics highlighting the error, along with suggested fixes. Clicking on those suggested fixes should resolve the problem. Does that work for you?

Screenshot 2021-02-04 at 08 13 17

The problems pane is empty and there is no indication, which go.mod has the problem (which made it so confusing). As with @samstride the error indicator in the status line keeps spinning.

We have also been working on improving the error message, and I believe that will be addressed in an upcoming release.

If you think it's fixed then happy to close here.

@stamblerre
Copy link
Contributor

I would not expect the Problems pane to be empty, so that's definitely still an issue. Can you please share your gopls logs? Information on how to capture them can be found here.

@andig
Copy link
Contributor Author

andig commented Feb 4, 2021

Good morning :) Here we go: gopls.txt.zip

@stamblerre
Copy link
Contributor

Looks like the issue is in the github.com/andig/evcc module.

[Error - 7:26:53 PM] 2021/02/03 19:26:53 go/packages.Load: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin github.com/andig/evcc/...]: exit status 1: go: updates to go.sum needed, disabled by -mod=readonly

	snapshot=0
	directory=/Users/andig/htdocs/evcc
	query=[builtin github.com/andig/evcc/...]
	packages=0

Do you still not see diagnostics on the go.mod file for that module? Does running go mod tidy in that module resolve the problem?

If not, it looks like that module is public--would you be willing to create a branch with a repro case for us to continue investigating?

@andig
Copy link
Contributor Author

andig commented Feb 4, 2021

Restarted vscode. This time, no spinner/error in status bar but message in problems view.

Do you still not see diagnostics on the go.mod file for that module?

No, gone. I'm wondering if the "sticky" errors are similar to #43821? Let's ignore that aspect and wait for go 1.16.

Now I'm getting output in the problem view. I still see an error there for a different module, however there's no fix available:

Screenshot 2021-02-04 at 09 18 38

The problematic module here is outside the workspace (one level higher). Looking into this and running go mod tidy I see similar behaviour as #42250:

  • I have simple testing ode in the parent folder for quick trial and errors
  • I have added a go.mod there to avoid recursively going up the tree
  • I still see that go mod update would go berserk and download the internet until it finally fails with a sirupsen/Logrus error

Long story short: I should not do this. I've moved the code from the parent folder to new and separate testing folder.

Shall we close here?

@stamblerre stamblerre removed this from the gopls/unplanned milestone Feb 4, 2021
@golang golang locked and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants