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

Trouble building with bazel #801

Closed
derekperkins opened this issue Aug 14, 2023 · 3 comments
Closed

Trouble building with bazel #801

derekperkins opened this issue Aug 14, 2023 · 3 comments

Comments

@derekperkins
Copy link

derekperkins commented Aug 14, 2023

Describe the bug
I'm using this library transitively via https://github.com/bufbuild/protovalidate-go, and while go builds succeed, bazel builds fail. I see that there are bazel files in this repo, is there something I should do to make builds succeed? No proto compilation happens inside bazel, generated files are committed.

Environment

  • protovalidate-go v0.2.1
  • bazel v6.3.2
  • go v1.21.0
  • rules_go v0.41.0
  • gazelle v0.32.0
  • github.com/google/cel-go v0.17.1

Additional context

'@com_github_google_cel_go//cel:cel': target 'cel' not declared in package 'cel' defined by /external/com_github_google_cel_go/cel/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/celext:celext'
'@com_github_google_cel_go//common/overloads:overloads': target 'overloads' not declared in package 'common/overloads' defined by /external/com_github_google_cel_go/common/overloads/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/celext:celext'
'@com_github_google_cel_go//common/types:types': target 'types' not declared in package 'common/types' defined by /external/com_github_google_cel_go/common/types/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/celext:celext'
'@com_github_google_cel_go//common/types/ref:ref': target 'ref' not declared in package 'common/types/ref' defined by /external/com_github_google_cel_go/common/types/ref/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/celext:celext'
'@com_github_google_cel_go//common/types/traits:traits': target 'traits' not declared in package 'common/types/traits' defined by /external/com_github_google_cel_go/common/types/traits/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/celext:celext'
'@com_github_google_cel_go//ext:ext': target 'ext' not declared in package 'ext' defined by /external/com_github_google_cel_go/ext/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/celext:celext'
'@com_github_google_cel_go//cel:cel': target 'cel' not declared in package 'cel' defined by /external/com_github_google_cel_go/cel/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/expression:expression'
'@com_github_google_cel_go//interpreter:interpreter': target 'interpreter' not declared in package 'interpreter' defined by /external/com_github_google_cel_go/interpreter/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/expression:expression'
'@com_github_google_cel_go//cel:cel': target 'cel' not declared in package 'cel' defined by /external/com_github_google_cel_go/cel/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/constraints:constraints'
'@com_github_google_cel_go//cel:cel': target 'cel' not declared in package 'cel' defined by /external/com_github_google_cel_go/cel/BUILD.bazel and referenced by '@com_github_bufbuild_protovalidate_go//internal/evaluator:evaluator'
@TristonianJones
Copy link
Collaborator

@derekperkins have you tried a standalone bazel build of cel-go? Our continuous build seems to be just fine.

@derekperkins
Copy link
Author

Digging deeper, I think this is an issue with how gazelle is dealing with the BUILD.bazel files already here for anyone using cel-go as a dependency. The issue was reported here, and a speculative fix is here, but not merged.

@derekperkins
Copy link
Author

I was able to track down the issue and get it fixed with a workaround. The actual issue is that gazelle isn't quite smart enough to handle repos like cel-go that already have bazel files. For anyone who finds this issue, the workaround is to manually add build_naming_convention = "go_default_library", to to the go_repository.

    go_repository(
        name = "com_github_google_cel_go",
        build_file_proto_mode = "disable_global",
        build_naming_convention = "go_default_library",
        importpath = "github.com/google/cel-go",
        sum = "h1:s2151PDGy/eqpCI80/8dl4VL3xTkqI/YubXLXCFw0mw=",
        version = "v0.17.1",
    )

If this underlying issue with gazelle is resolved, this manual workaround shouldn't be needed in the future.

Thanks for responding @TristonianJones

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

2 participants