-
-
Notifications
You must be signed in to change notification settings - Fork 685
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
rules_go 0.40+ broke gopls resolving stdlib imports in VS code #3741
Comments
Could you provide the output of |
I saved the output for 0.39.1 and 0.40.1 and also a diff between them. To be able to generate the diff, it used |
Do you know what gopls version you're running? the outputs you shared seem normal 🤔 |
Sorry for the year long silence. I think I found the reason: During the initial load of the workspace, gopackagesdriver does not provide any files for "CompiledGoFiles" for stdlib packages. gopls then drops these imports in https://github.com/golang/tools/blob/8171d94fe98a51fb8471b40726983dd098a3fde6/gopls/internal/cache/load.go#L533-L536 (except for "unsafe"). This then results in gopls reporting that the import could not be found (the error now is "go/packages driver could not load $PKG"). I played around with the request as well (gopls sends sth like My test one-liner was:
Which then resulted in
but then subsequent runs result in this:
|
Correction, it seems to fluctuate: for i in $(seq 1 10); do echo '{"mode":32287,"env":[], "build_flags":null,"tests":true,"overlay":{}}' | ./scripts/gopackagesdriver.sh ./... builtin 2>/dev/null | jq '.Packages[] | select(.ID == "@@rules_go+//stdlib:os") | .CompiledGoFiles | length'; done
36
0
0
36
0
0
36
0
0
0 |
That made it worse:
But I was able to reduce the problem to a single rule: Looks like this only happens for packages which have tests with When running gopackagesdriver for the |
What version of rules_go are you using?
Tested with 0.40.1 and 0.42
What version of gazelle are you using?
0.31.1 and 0.33
What version of Bazel are you using?
6.4.0
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
Linux amd64
Any other potentially useful information about your toolchain?
Tested with gopls 0.13.2 and 0.14.1.
Using these settings in VS code:
and this
gopackagesdriver.sh
:What did you do?
Updated rules_go from 0.39.1 to 0.42 (and then later backtracked the problem to 0.40)
What did you expect to see?
gopls is able to resolve stdlib imports in VS code as before.
What did you see instead?
A lot of import errors in the format of
could not import $PKG (cannot find packge "$PKG" in GOROOT or GOPATH)
.The text was updated successfully, but these errors were encountered: