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: when using go.work in GOROOT, "gopls requires a module at the root of your workspace" #48022

Closed
jayconrod opened this issue Aug 27, 2021 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@jayconrod
Copy link
Contributor

ATTENTION: Please answer these questions BEFORE submitting your issue. Thanks!

What did you do?

  • Add the following go.work file in GOROOT:
go 1.18

directory (
	src
	src/cmd
)
  • Checkout a recent commit of Go. I was reviewing CL 345390, so this should get what I had:
git fetch https://go.googlesource.com/go refs/changes/90/345390/1 && git checkout FETCH_HEAD
  • Run make.bash, reload VSCode window (workspace root is GOROOT), open some files.
  • NOTE: this is my workspace settings.json, so I think gopls should be using cmd/go built in that GOROOT.
{
  "go.alternateTools": {
    "go": "/Users/jayconrod/Code/goroot/bin/go"
  }
}

What did you expect to see?

No errors, everything working normally.

What did you see instead?

On the VSCode status bar, I see a spinning arrow animation with the error:

gopls requires a module at the root of your workspace.
You can work with multiple modules by opening each one as a workspace folder.
Improvements to this workflow will be coming soon, and you can learn more here:
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.

I also see a red squiggly line with this error under the go directive in go.work. It also shows up on the package declaration in each .go file I open.

Build info

golang.org/x/tools/gopls v0.7.1
    golang.org/x/tools/gopls@v0.7.1 h1:Mh3Z8Xcoq3Zy7ksSlwDV/nzQSbjFf06A+L+F8YHq55U=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
    golang.org/x/sys@v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
    golang.org/x/tools@v0.1.6-0.20210802203754-9b21a8868e16 h1:ZC/gVBZl8poJyKzWLxxlsmhayVGosF4mohR35szD5Bg=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.2.0 h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
    mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
@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 Aug 27, 2021
@gopherbot gopherbot added this to the Unreleased milestone Aug 27, 2021
@jayconrod
Copy link
Contributor Author

I normally see this error when working in GOROOT without go.work, but gopls seems to work fine otherwise, so I ignore it and hide the status bar so the error animation doesn't distract me. I don't think this should happen with a go.work file though.

@hyangah hyangah modified the milestones: Unreleased, gopls/on-deck Aug 30, 2021
@stamblerre stamblerre removed their assignment Oct 19, 2021
@sabuhigr
Copy link

any fixing ?

@findleyr findleyr self-assigned this Jan 27, 2022
@findleyr
Copy link
Contributor

findleyr commented Feb 7, 2022

With go.work on 1.18, this now behaves correct (using gopls@master)

@findleyr findleyr closed this as completed Feb 7, 2022
@findleyr findleyr modified the milestones: gopls/on-deck, gopls/v0.8.0 Feb 8, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
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. release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants