Skip to content
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

Issue building with Bazel #1759

Open
kylekurz opened this issue Nov 22, 2022 · 3 comments
Open

Issue building with Bazel #1759

kylekurz opened this issue Nov 22, 2022 · 3 comments

Comments

@kylekurz
Copy link

Associated rules_go issue here: bazel-contrib/rules_go#3357

I added Bleve to our application dependencies and Bazel can no longer complete its build process. It appears that there is something different in the layout/configuration of Bleve that triggers this, as all my other dependencies build with Bazel with no adjustments. Repro repository here: https://github.com/kylekurz/bleve-issue-example

@kylekurz
Copy link
Author

Big thanks to @chadxz for looking into this with me, we have some progress. I believe Gazelle is ignoring the upsidedown.pb.go file due to this change (which seems resonable): https://github.com/bazelbuild/bazel-gazelle/pull/840/files

The idea being that if the proto file is available, Gazelle should rely on building the library from the included .proto file. I'm still researching how to narrow down what is confusing it from there.

@kylekurz
Copy link
Author

kylekurz commented Nov 27, 2022

I noticed that the code generator for the checked-in .pb.go file was different than the one used by Bazel. After setting a couple Gazelle directives, I got this closer:

# gazelle:go_proto_compilers @io_bazel_rules_go//proto:gogofaster_proto
# gazelle:proto file

Error changed to:

index/upsidedown/dump.go:132:64: invalid operation: cannot indirect entry.Field (variable of type uint32)
index/upsidedown/upsidedown.go:598:53: cannot use proto.Uint32(uint32(fieldIndex)) (value of type *uint32) as type uint32 in struct literal
index/upsidedown/upsidedown.go:626:52: cannot use proto.Uint32(uint32(fieldIndex)) (value of type *uint32) as type uint32 in struct literal
index/upsidedown/upsidedown.go:704:72: invalid operation: cannot indirect backIndexEntry.Field (variable of type uint32)
index/upsidedown/upsidedown.go:709:39: invalid operation: cannot indirect se.Field (variable of type uint32)

This seems like progress, but I'm not familiar enough with Bleve's build process to know if it is or not.

@kylekurz
Copy link
Author

@chadxz figured out we can disable protobuf for just this dependency and it works. However, I still think there's a fundamental issue with the protobuf configuration of this library, given that it requires overrides.

Here's the workaround for anyone else that runs across this while this issue is open. Add Bleve to your deps.bzl explicitly, but disable protobuf:

go_repository(
        name = "com_github_blevesearch_bleve_v2",
        build_file_proto_mode = "disable",  # keep
        importpath = "github.com/blevesearch/bleve/v2",
        sum = "h1:1wuR7eB8Fk9UaCaBUfnQt5V7zIpi4VDok9ExN7Rl+/8=",
        version = "v2.3.5",
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant