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

[BUG] Cannot build with Bzlmod #88

Open
debkanchan opened this issue Dec 21, 2023 · 13 comments
Open

[BUG] Cannot build with Bzlmod #88

debkanchan opened this issue Dec 21, 2023 · 13 comments
Assignees
Labels
Bug Something isn't working

Comments

@debkanchan
Copy link

debkanchan commented Dec 21, 2023

Description

I'm using the upcoming bzlmod support in rules_buf and I've encountered this error.

ERROR: /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go/celext/BUILD.bazel:3:11: no such target '@gazelle~0.34.0~go_deps~com_github_google_cel_go//cel:cel': target 'cel' not declared in package 'cel' defined by /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_google_cel_go/cel/BUILD.bazel (Tip: use `query "@@gazelle~0.34.0~go_deps~com_github_google_cel_go//cel:*"` to see all the targets in that package) and referenced by '@gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go//celext:celext'
ERROR: /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go/celext/BUILD.bazel:3:11: no such target '@gazelle~0.34.0~go_deps~com_github_google_cel_go//common/overloads:overloads': target 'overloads' not declared in package 'common/overloads' defined by /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_google_cel_go/common/overloads/BUILD.bazel (did you mean 'overloads.go'? Tip: use `query "@@gazelle~0.34.0~go_deps~com_github_google_cel_go//common/overloads:*"` to see all the targets in that package) and referenced by '@gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go//celext:celext'
ERROR: /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go/celext/BUILD.bazel:3:11: no such target '@gazelle~0.34.0~go_deps~com_github_google_cel_go//common/types:types': target 'types' not declared in package 'common/types' defined by /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_google_cel_go/common/types/BUILD.bazel (Tip: use `query "@@gazelle~0.34.0~go_deps~com_github_google_cel_go//common/types:*"` to see all the targets in that package) and referenced by '@gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go//celext:celext'
ERROR: /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go/celext/BUILD.bazel:3:11: no such target '@gazelle~0.34.0~go_deps~com_github_google_cel_go//common/types/ref:ref': target 'ref' not declared in package 'common/types/ref' defined by /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_google_cel_go/common/types/ref/BUILD.bazel (Tip: use `query "@@gazelle~0.34.0~go_deps~com_github_google_cel_go//common/types/ref:*"` to see all the targets in that package) and referenced by '@gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go//celext:celext'
ERROR: /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go/celext/BUILD.bazel:3:11: no such target '@gazelle~0.34.0~go_deps~com_github_google_cel_go//common/types/traits:traits': target 'traits' not declared in package 'common/types/traits' defined by /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_google_cel_go/common/types/traits/BUILD.bazel (Tip: use `query "@@gazelle~0.34.0~go_deps~com_github_google_cel_go//common/types/traits:*"` to see all the targets in that package) and referenced by '@gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go//celext:celext'
ERROR: /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go/celext/BUILD.bazel:3:11: no such target '@gazelle~0.34.0~go_deps~com_github_google_cel_go//ext:ext': target 'ext' not declared in package 'ext' defined by /private/var/tmp/_bazel_debkanchan/969f704a68afbe6aa6f76e61ecfa9c99/external/gazelle~0.34.0~go_deps~com_github_google_cel_go/ext/BUILD.bazel (Tip: use `query "@@gazelle~0.34.0~go_deps~com_github_google_cel_go//ext:*"` to see all the targets in that package) and referenced by '@gazelle~0.34.0~go_deps~com_github_bufbuild_protovalidate_go//celext:celext'

Steps to Reproduce

Environment

  • Operating System: macOS
  • Version: macOS 14.1.2 23B92 arm64
  • Compiler/Toolchain: Bazel
  • Protobuf Compiler & Version: buf 1.28.1
  • Protovalidate Version: v0.4.3

Possible Solution

in #27 a possible solution includes manually changing go_repository arguments in go_deps.bzl. Since bzlmod support means there's no go_deps.bazel file anymore where I could manually change settings I'm stuck as it seems.

Additional Context

MODULE

"""
This is the MODULE.bazel file. It defines the dependencies for the Bazel build system.
"""
bazel_dep(name = "rules_go", version = "0.42.0")

bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True)

bazel_dep(name = "rules_pkg", version = "0.9.1")
bazel_dep(name = "rules_oci", version = "1.5.1")

# TODO: remove this later. See https://github.com/bazel-contrib/rules_oci/issues/425#issuecomment-1860211483
bazel_dep(name = "aspect_bazel_lib", version = "2.0.3")
bazel_dep(name = "container_structure_test", version = "1.16.0")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

use_repo(go_deps, "build_buf_gen_go_bufbuild_protovalidate_protocolbuffers_go", "build_buf_gen_go_ride_wallet_connectrpc_go", "build_buf_gen_go_ride_wallet_protocolbuffers_go", "com_connectrpc_connect", "com_github_bufbuild_protovalidate_go", "com_github_golang_jwt_jwt_v5", "com_github_google_wire", "com_github_ilyakaznacheev_cleanenv", "com_github_micahparks_keyfunc_v2", "com_github_mmcloughlin_geohash", "com_github_onsi_ginkgo_v2", "com_github_onsi_gomega", "com_google_cloud_go_firestore", "com_google_firebase_go_v4", "org_golang_google_genproto", "org_golang_google_genproto_googleapis_api", "org_golang_google_grpc", "org_golang_google_protobuf", "org_golang_x_net", "org_uber_go_mock", "org_uber_go_zap")

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
    name = "distroless",
    digest = "sha256:112a87f19e83c83711cc81ce8ed0b4d79acd65789682a6a272df57c4a0858534",
    image = "gcr.io/distroless/static",
    platforms = [
        "linux/amd64",
        "linux/arm64/v8",
    ],
)

# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "distroless")

BUILD

load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
load("@gazelle//:def.bzl", "gazelle")

# gazelle:prefix github.com/ride-app/driver-service
# gazelle:build_file_name BUILD.bazel
# gazelle:exclude infra
# gazelle:proto disable_global
gazelle(
    name = "gazelle",
)

buildifier(
    name = "buildifier",
)
@debkanchan debkanchan added the Bug Something isn't working label Dec 21, 2023
@debkanchan
Copy link
Author

@srikrsna-buf @rodaine

@debkanchan
Copy link
Author

@srikrsna-buf @rodaine any solutions?

@debkanchan
Copy link
Author

@srikrsna-buf @rodaine still stuck on this

@srikrsna-buf
Copy link
Member

Hey! I am not sure if it is a problem with rules_buf, I don't see it used in the MODULE file. This could be problem of rules_go because bufbuild/protovalidate-go is a regular go module and doesn't have any bazel specific code.

@debkanchan
Copy link
Author

@srikrsna-buf it's not a problem with rules_buf but rather protovalidate library

@srikrsna-buf
Copy link
Member

You can replicate the solution in #27 using go_deps.module. More on this in the rules_go docs: https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/bzlmod.md#specifying-external-dependencies

@srikrsna-buf
Copy link
Member

Looks like they removed those options and moved it to a directive

@debkanchan
Copy link
Author

even after doing that it throws the same error

@srikrsna-buf
Copy link
Member

Can you share the directives you've used?

@andrewryno
Copy link

I hit this as well and these directives seem to have worked (I'm hitting other issues on other packages like @io_etcd_go_etcd_api_v3) but I can now get past the errors relating to cel-go:

# gazelle:resolve go github.com/google/cel-go/cel @com_github_google_cel_go//cel:go_default_library
# gazelle:resolve go github.com/google/cel-go/checker/decls @com_github_google_cel_go//checker/decls:go_default_library
# gazelle:resolve go github.com/google/cel-go/common/types @com_github_google_cel_go//common/types:go_default_library
# gazelle:resolve go github.com/google/cel-go/interpreter @com_github_google_cel_go//interpreter:go_default_library

Those are the packages we're importing so change to whichever ones you are using.

@debkanchan
Copy link
Author

Can you share the directives you've used?

# gazelle:prefix github.com/ride-app/driver-service
# gazelle:build_file_name BUILD.bazel
# gazelle:exclude infra
# gazelle:proto disable_global
# gazelle:go_naming_convention go_default_library

@debkanchan
Copy link
Author

I hit this as well and these directives seem to have worked (I'm hitting other issues on other packages like @io_etcd_go_etcd_api_v3) but I can now get past the errors relating to cel-go:

# gazelle:resolve go github.com/google/cel-go/cel @com_github_google_cel_go//cel:go_default_library
# gazelle:resolve go github.com/google/cel-go/checker/decls @com_github_google_cel_go//checker/decls:go_default_library
# gazelle:resolve go github.com/google/cel-go/common/types @com_github_google_cel_go//common/types:go_default_library
# gazelle:resolve go github.com/google/cel-go/interpreter @com_github_google_cel_go//interpreter:go_default_library

Those are the packages we're importing so change to whichever ones you are using.

I tried your solution but still throws some errors. Would you mind sharing the whole gazelle setup in BUILD.bazel?

@debkanchan
Copy link
Author

I hit this as well and these directives seem to have worked (I'm hitting other issues on other packages like @io_etcd_go_etcd_api_v3) but I can now get past the errors relating to cel-go:

# gazelle:resolve go github.com/google/cel-go/cel @com_github_google_cel_go//cel:go_default_library
# gazelle:resolve go github.com/google/cel-go/checker/decls @com_github_google_cel_go//checker/decls:go_default_library
# gazelle:resolve go github.com/google/cel-go/common/types @com_github_google_cel_go//common/types:go_default_library
# gazelle:resolve go github.com/google/cel-go/interpreter @com_github_google_cel_go//interpreter:go_default_library

Those are the packages we're importing so change to whichever ones you are using.

I tried your solution but still throws some errors. Would you mind sharing the whole gazelle setup in BUILD.bazel?

@andrewryno

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants