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

Problems with 'validate_proto' not declared in package 'validate' #1199

Closed
GiulianoWF opened this issue Dec 11, 2024 · 4 comments · Fixed by #1226
Closed

Problems with 'validate_proto' not declared in package 'validate' #1199

GiulianoWF opened this issue Dec 11, 2024 · 4 comments · Fixed by #1226
Labels
Bazel Bazel related issues C++ C++ language support Good First Issue Newcomer-friendly issue Help Wanted Community support requested

Comments

@GiulianoWF
Copy link

Curently when I try to build my project I get:

ERROR: Traceback (most recent call last):
        File "/home/user/.cache/bazel/_bazel_user/43633c363e7fef7d5294d9a3f2e8c154/external/protoc-gen-validate~/validate/BUILD", line 3, column 47, in <toplevel>
                load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library")
Error: file '@rules_cc//cc:defs.bzl' does not contain symbol 'cc_proto_library'
ERROR: /home/user/.cache/bazel/_bazel_user/43633c363e7fef7d5294d9a3f2e8c154/external/protoc-gen-validate~/validate/BUILD: no such target '@@protoc-gen-validate~//validate:validate_proto': target 'validate_proto' not declared in package 'validate' defined by /home/user/.cache/bazel/_bazel_user/43633c363e7fef7d5294d9a3f2e8c154/external/protoc-gen-validate~/validate/BUILD

It seams that the version of rules_cc that is being used does not correspond to the version expected by protoc-gen-validate?

my modules:

bazel_dep(name = "protoc-gen-validate", version = "1.0.4")
bazel_dep(name = "rules_proto_grpc_cpp", version = "5.0.0")
bazel_dep(name = "grpc", version = "1.68.0")
bazel_dep(name = "protobuf", version = "27.1")
bazel_dep(name = "abseil-cpp", version = "20240116.2")
bazel_dep(name = "zlib", version = "1.3.1.bcr.3")

and the config:

bazel_dep(name = "toolchains_protoc", version = "0.3.6")

protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
protoc.toolchain(
    google_protobuf = "com_google_protobuf",
    version = "v27.1",
)
use_repo(protoc, "com_google_protobuf", "toolchains_protoc_hub")

register_toolchains("@toolchains_protoc_hub//:all")

Any idea what can I do?

@rodaine rodaine added Help Wanted Community support requested Good First Issue Newcomer-friendly issue C++ C++ language support Bazel Bazel related issues labels Dec 11, 2024
@kgreenek
Copy link
Contributor

This hit me as well.

rules_cc has removed cc_proto_library as of v0.1.0.

See the Incompatible Changes section here:
https://github.com/bazelbuild/rules_cc/releases/tag/0.1.0

The fix is to use cc_proto_library from com_google_protobuf instead. Like so:

load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")

@kgreenek
Copy link
Contributor

The rules_proto repo has been deprecated entirely as well.

It should no longer be used.

See the README here:
https://github.com/bazelbuild/rules_proto

Instead, proto_library should be imported from com_google_protobuf as well. Like so:

load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")

@kgreenek
Copy link
Contributor

I'll take a stab at removing @rules_proto as a dependency and updating to the latest protobuf.

kgreenek added a commit to kgreenek/protoc-gen-validate that referenced this issue Dec 27, 2024
Closes bufbuild#1199

rules_proto has been deprecated and should no longer be used.

rules_cc removed the proto-related bazel rules as of 0.1.0. Instead,
these rules now live in com_google_protobuf and should be used from
there.

Several other dependencies also had to be updated to support the changes
in com_google_protobuf and cc_proto.
@kgreenek
Copy link
Contributor

I believe I have fixed the issue for this repo in #1210.

This problem will also affect rules_buf and gazelle as well, since gazelle generates build files which currently use rules_proto.

kgreenek added a commit to kgreenek/protoc-gen-validate that referenced this issue Jan 16, 2025
rodaine pushed a commit that referenced this issue Jan 16, 2025
Closes #1199

This is a more minimal change to simply migrate away from rules_cc's
cc_proto_library without updating all the external deps.

This will prepare for the upcoming 0.1.X release of rules_cc where
cc_proto_library is removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bazel Bazel related issues C++ C++ language support Good First Issue Newcomer-friendly issue Help Wanted Community support requested
Projects
None yet
3 participants