-
Notifications
You must be signed in to change notification settings - Fork 385
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
Gazelle unable to resolve external Go library from go.mod. Manually adding to use_repo
list works around it, but bazel mod tidy removes it.
#1983
Comments
Could you share the content of your |
Thanks for looking into this! I had to make one additional change in |
Hi @fmeum, were you able to reproduce the issue with that repo? Is there anything else I can provide to help debug this? |
I did a bit more digging into this and I think this comes down to this dependency being incorrectly marked as an indirect dependency (probably due to something I did incorrectly when adding the dependency, but I don't recall exactly what steps I used). This dependency is being used directly in my Go code, which I thought would be picked up by Gazelle so that it could deduce that it's a direct dependency rather than an indirect dependency, but that doesn't appear to be how that works. I was able to mark that dependency as a direct dependency via Since I'm using Originally I think I must have attempted to "install" this dependency without the use of |
Gazelle gives you access to everything in Ideally you would get |
That makes sense, thanks for clarifying! The |
What version of gazelle are you using?
0.40.0
What version of rules_go are you using?
0.50.1
What version of Bazel are you using?
Bazelisk version: 1.24.0
Bazel version: 7.4.1
Does this issue reproduce with the latest releases of all the above?
Yes, I made sure to update everything mentioned above and retest. Unfortunately I'm still running into the same issue.
What operating system and processor architecture are you using?
Working within Ubuntu (amd64) on WSL2 on a Windows 11 host machine.
What did you do?
I recently added these two imports to my project:
To do this, I followed these steps:
bazel run @rules_go//go -- get github.com/lestrrat-go/jwx/v3/jwt
andbazel run @rules_go//go -- get github.com/lestrrat-go/jwx/v3/jwa
.go.mod
file was updated to include the underlying importgithub.com/lestrrat-go/jwx/v3
.bazel run //:gazelle
at the root of the project to update the associatedBUILD
file.bazel mod tidy --enable_bzlmod
at the root of the project (didn't make any changes).oci_load
from@rules_oci
, but theoretically this would apply to a simplego build
target as well.What did you expect to see?
I expected to see that the target ran successfully.
What did you see instead?
The target failed with the following error message, seemingly unable to resolve the new external import:
Out of curiosity, I tried running the aforementioned target again after manually adding
"com_github_lestrrat_go_jwx_v3"
to the list of dependencies passed touse_repo
in myMODULE.bazel
file and it ran successfully. Although it did print an error pointing out that an indirect dependency was in that list and I should runbazel mod tody
to fix it. Running that command removes the explicit import I added, but as a result the original target fails to build again.Reference - Contents of Relevant Files
MODULE.bazel
//src/services/identity/BUILD
Snippet of imports from //src/services/identity/service.go
My questions
Is there something special about this repository that requires an override? I'm not keenly aware of Gazelle's override options and where they might be used. I'd really appreciate some guidance on that front if possible!
The repository for the import I'm using is here: https://github.com/lestrrat-go/jwx. It appears that
jwt
andjwa
are sub-folders rather than separate repositories, which explains the changes to mygo.mod
. The repository is bazel-compatible, but it is not using the newer Bzlmod format.I'm also not entirely clear on the difference between direct and indirect dependencies as far as Gazelle is concerned. This dependency is explicitly listed in the BUILD file for the go file that uses it, so I assumed it would be considered a direct dependency of the project. However,
bazel mod tidy
seems to consider it indirect instead and I don't fully understand why that is. What's the meaning of direct vs indirect in that context?The text was updated successfully, but these errors were encountered: