-
Notifications
You must be signed in to change notification settings - Fork 386
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 and go.mod versioning #537
Comments
/cc @asuffield |
If you go into the minio directory in .../external and do a |
OK, @asuffield figured it out, this is because gazelle is not reading the |
this can be fixed using the repository_macro directive in your workspace, introduced in 4f524f2 E.g. # gazelle: repository_macro deps.bzl%defName |
The last piece of this puzzle is that the dependency on the other repo is itself in a go_repository rule, and we are running without direct internet access. With vanilla gazelle, this doesn't currently work at all. With internet access, it can resolve the path via http query. With the usage in the root repository, the repository_macro directive works. When it's a go_repository rule, I have a patch to gazelle that I keep meaning to turn into a PR, which passes the WORKSPACE file to the gazelle invocations so that it can use entries in that file to resolve importpaths to repo names. However, that doesn't have a good solution for repository_macro (one of the reasons why I haven't sent that PR yet): in general there's no way to tell which files gazelle might need to read. We might need a bazel feature to do something like aspects for repository rules, in order to extract this data reliably. In the general case, at the time when go_repository is executing, the rest of the things included in WORKSPACE have not even been parsed yet, and might not be parseable without completing this gazelle invocation. This is tricksy. |
About the original issue, some fixes for importing modules have been merged to Once you upgrade, you should be able to have a repository rule like this;
If you have a working
Don't do this. Repository rules will be re-evaluated whenever anything they depend on changes, which means their directories are deleted.
Not sure what's happening here? Is this a manually written go.mod file? It should work, but make sure the macro inside it is loaded and called from WORKSPACE.
This tells Gazelle to update rules declared in that macro when
I'm not sure how this would work at all without network access.
This should work in the main repository, maybe since #493. Sorry it's not released yet, but try a newer commit from Custom repository names aren't known within |
We have a contraption to fetch archives via an asset management thing - but gazelle's direct http queries for golang metadata do not (currently) work, so we completely rely on picking up the repository names from WORKSPACE to resolve them. #529 is indeed precisely what my locally-applied patch addresses, partially. I've been sitting on it for a while, trying to figure out how to get something like repository_macro to work with it. |
I'll close this issue since #529 seems to cover all missing functionality. Happy to answer questions though. I think the solution to #529 will involve invoking Gazelle with a flag telling it that it's in a As a workaround, there is a |
Hello,
The minio-go projects uses this in the their
go.mod
file:I.e. they tag on
v6
, with some triggery (and using gazelle version 0.17) I generate a build file that has the correct importpath:importpath = "github.com/minio/minio-go/v6
however when buiding bazel complains:IIRC in the go modules proposal adding strings that start with
v
are supposed to be handled in a special way (but I'll have to check)The text was updated successfully, but these errors were encountered: