You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ChristoWolf opened this issue
Jan 26, 2023
· 2 comments
Labels
goplsIssues related to the Go language server, gopls.NeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.
Check your installed extensions to get the version of the VS Code Go extension
v0.37.1
Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
Workspace Folder (devTools): c:\dev\devTools
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\cwolf\AppData\Local\go-build
set GOENV=C:\Users\cwolf\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\cwolf\go\pkg\mod
set GONOPROXY=redacted
set GONOSUMDB=redacted
set GOOS=windows
set GOPATH=C:\Users\cwolf\go
set GOPRIVATE=redacted
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=c:\dev\devTools\go.work
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\cwolf\AppData\Local\Temp\go-build1196747904=/tmp/go-build -gno-record-gcc-switches
I also had GOWORK= before, but that led to the same issue.
Share the Go related settings you have added/edited
A clear and concise description of what the bug is:
In my workspace folder I have a go.work file containing my relative module paths in that folder.
Still, I get the following persistent error notification:
Error loading workspace: packages.Load error: err: exit status 1: stderr: cannot find package "integration" in any of: C:\Program Files\Go\src\integration (from $GOROOT) C:\Users\cwolf\go\src\integration (from $GOPATH) cannot find package "-e" in any of: C:\Program Files\Go\src\-e (from $GOROOT) C:\Users\cwolf\go\src\-e (from $GOPATH) cannot find package "-f" in any of: C:\Program Files\Go\src\-f (from $GOROOT) C:\Users\cwolf\go\src\-f (from $GOPATH) cannot find package "{{context.ReleaseTags}}" in any of: C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT) C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH) cannot find package "--" in any of: C:\Program Files\Go\src\-- (from $GOROOT) C:\Users\cwolf\go\src\-- (from $GOPATH)
I have no idea why these are being probed, because they do not exist at all and are not referenced anywhere.
The ones with hyphens do not even make sense of course.
The integration is also not a package but a go:build flag that I have at the top of a test file, which works as expected.
I think the problem is your "buildFlags" setting. It looks like you are trying to set the "integration" build tag, but in that case it should be "-tags=integration".
It looks like gopls is passing the build flags unmodified to the go command, and that's why "-e" (which is probably passed after build tags) is interpreted as a non-flag argument.
This is messy, and we should validate build flags to produce a better error.
findleyr
changed the title
Workspace attempts to load non-existent packages
x/tools/gopls: validate that user build flags are actually flags
Jan 26, 2023
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
Jan 26, 2023
That was of course also my first thought, but when I first encountered the issue I tried to disable the buildFlags, but it did not fix the issue.
Now with your reply I tried it out again and also restarted VS Code (and by that also gopls) and it worked.
So that was just a false positive from my side.
Anyway, your answer helped me resolve my issue, thanks a ton!
This is messy, and we should validate build flags to produce a better error.
I think that would be quite helpful!
One could also argue that the current error message is already telling (I mean, it was, because we both already knew what the cause could be), but improving it would certainly improve the experience.
goplsIssues related to the Go language server, gopls.NeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.97dec172d3256f8ca4bfb2143f3f76b503ca0534
x64
Go: Locate Configured Go Tools
command.I also had
GOWORK=
before, but that led to the same issue.Share the Go related settings you have added/edited
Describe the bug
A clear and concise description of what the bug is:
In my workspace folder I have a
go.work
file containing my relative module paths in that folder.Still, I get the following persistent error notification:
I have no idea why these are being probed, because they do not exist at all and are not referenced anywhere.
The ones with hyphens do not even make sense of course.
The
integration
is also not a package but ago:build
flag that I have at the top of a test file, which works as expected.Further, when I set
all modules inside the workspace folder are marked as red because the error above is shown inside the mod files, and the notification still persists.
The
gopls (server)
OUTPUT
shows:Either way, everything builds and runs as expected despite these issues.
A clear and concise description of what you expected to happen.
That no non-existent packages/modules are tried to be loaded.
Steps to reproduce the behavior:
gopls (server)
OUTPUT
.The text was updated successfully, but these errors were encountered: