-
Notifications
You must be signed in to change notification settings - Fork 651
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
GOPACKAGESDRIVER_BAZEL_QUERY_SCOPE implementation is not with "./..." and "bultin" args at the same time #3999
Comments
Relevant code in master as of time of this writing 2024-07-30: rules_go/go/tools/gopackagesdriver/bazel_json_builder.go Lines 122 to 145 in 634fc28
It seems if bazelQueryScope != null we just assume packageQuery and that mishandles builtin and ./... At a super high level, I suspect this older code from April 2023 is closer to correct: rules_go/go/tools/gopackagesdriver/bazel_json_builder.go Lines 89 to 115 in ec5a27c
Maybe one change I would make is to add all kinds to the bazelQueryScope?
|
CC @JamyDev |
What version of rules_go are you using?
v0.46.0
What version of gazelle are you using?
v0.35.0
What version of Bazel are you using?
6.3.2
Does this issue reproduce with the latest releases of all the above?
Probably yes, I can try later but my understanding of the code is that it is a problem with how GOPACKAGESDRIVER_BAZEL_QUERY_SCOPE was implemented.
What operating system and processor architecture are you using?
Linux AMD64
Any other potentially useful information about your toolchain?
N/A
What did you do?
While trying to use rules_go gopackagedriver with VSCode IDE, I noticed that if GOPACKAGESDRIVER_BAZEL_QUERY_SCOPE is used we seem to be getting no results back.
Using a wrapper script I was able to determine what the arguments VSCode (through gopls) give to rules_go's gopackagedriver. The arguments were "./..." and "bultin".
Below is the minimum reproducible snippet:
Result:
I believe the comment in this PR by @fmeum : https://github.com/bazelbuild/rules_go/pull/3688/files#r1321005945 is particularly relevant. There is an implicit assumption that if GOPACKAGESDRIVER_BAZEL_QUERY_SCOPE all queries need to be
kind("%s", attr(importpath, "%s", deps(%s)))
type of query. I would argue the right behavior is actually intersection withdeps($GOPACKAGESDRIVER_BAZEL_QUERY_SCOPE)
which seems related to what the comment suggestedYou can see in the output above that for handling the builtin request we should definetly not be using
kind("go_library", attr(importpath, "builtin", deps(//path/to/my/target))
as searching on importpath = bultin is probably not what was intended.What did you expect to see?
I was expecting to have at least some packages returned back and for them to be transitive dependencies of the target I gave as the
GOPACKAGESDRIVER_BAZEL_QUERY_SCOPE
env variableWhat did you see instead?
No packages returned.
The text was updated successfully, but these errors were encountered: