Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conflict with rules proto: "cannot load '@rules_cc//cc:action_names.bzl': no such file" #8

Closed
gioannidis opened this issue Aug 22, 2021 · 3 comments · Fixed by #9
Closed

Comments

@gioannidis
Copy link

Overview

bazel_clang_tidy seems to conflict with protobuf rules from rules_proto.
The error I am getting is:

clang_tidy/clang_tidy.bzl: cannot load '@rules_cc//cc:action_names.bzl': no such file

Details below.

Steps to reproduce

  1. Clone the bazel_clang_tidy repository (as of this commit).

  2. Apply the 0001-Added-protobuf-external-dependency-and-sample-proto.patch.gz patch.

    • This inserts the rules dependencies from the rules_proto repository, updated to the latest commit.
    • It also adds a sample test.proto file.
  3. Build without invoking clang-tidy: works normally

    $ bazel build //example:app
    
  4. Build with clang-tidy aspect: raises error (see below)

    bazel build //example:app \
        --aspects clang_tidy/clang_tidy.bzl%clang_tidy_aspect \
        --output_groups=report
    

Detailed error message

Invoking the clang-tidy aspect with protobuf rules generates the following errors:

ERROR: in /path/to/bazel_clang_tidy/clang_tidy/clang_tidy.bzl: cannot load '@rules_cc//cc:action_names.bzl': no such file
ERROR: Analysis of aspect '//clang_tidy:clang_tidy.bzl%clang_tidy_aspect of //example:app' failed; build aborted: in /path/to/bazel_clang_tidy/clang_tidy/clang_tidy.bzl: cannot load '@rules_cc//cc:action_names.bzl': no such file
INFO: Elapsed time: 0.090s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

Offending line

Removing the following rule from WORKSPACE fixes the clang-tidy error, but breaks of course the compilation of //example:test.proto:

rules_proto_dependencies()
@gioannidis
Copy link
Author

Investigating this further, the root cause is at the rules_proto repository end, which fetches an older commit from rules_cc.

The rules_proto_dependencies() loads the rules_cc dependencies at commit b7fe969 (2019-07-22). However, the action_names.bzl (history) was created at a later point: 4a1c578 (2019-08-21).

One workaround is to add the following to the WORKSPACE file, after rules_proto_toolchains(), which resolves the issue by fetching the latest commit.

http_archive(
    name = "rules_cc",
    sha256 = "3cde212ccda3ba152897e7fd354c42eba275878b6d98fe4f2125c684a73f3842",
    strip_prefix = "rules_cc-d66a13e2a01630afcafc4ba411d83e291ecf02bd",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/d66a13e2a01630afcafc4ba411d83e291ecf02bd.tar.gz",
        "https://github.com/bazelbuild/rules_cc/archive/d66a13e2a01630afcafc4ba411d83e291ecf02bd.tar.gz",
    ],
)

I am not very experienced with the bazel rules, though. Is there a cleaner way to apply a patch to the rules_cc dependency?

@JulianNeeleman
Copy link

I ran into the same issue. Thanks @gioannidis for figuring out the root cause. For me, the build only succeeded after including your WORKSPACE snippet and the git_repository declaration for bazel_clang_tidy before declaring protobuf/gRPC dependencies.

@erenon
Copy link
Owner

erenon commented Aug 23, 2021

Thanks for reporting this. As a tactical measure, we can drop the dependency on "CPP_COMPILE_ACTION_NAME", and hardcode its current value.

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

Successfully merging a pull request may close this issue.

3 participants