aspect-build / rules_lint

Run static analysis tools with Bazel
Apache License 2.0
81 stars 44 forks source link

[Bug]: Undeclared dependence on bazel-lib 2.7.7 #351

Closed agoessling closed 2 months ago

agoessling commented 3 months ago

What happened?

The clang-tidy aspect contains an undeclared dependency on bazel-lib 2.7.7 (or at least one >2.5.0). If you pare the example module down to just the clang-tidy relevant code, you technically don't need to depend on bazel-lib directly, but when you remove this dependency the version in rules_lint (2.5.0) is insufficient. If you change the dependency in rules_lint to 2.7.7, things work as expected.

Version

Development (host) and target OS/architectures: linux x86

Output of bazel --version: bazel 7.2.1

Language(s) and/or frameworks involved: C/C++ clang-tidy

How to reproduce

1. Clone this branch: https://github.com/agoessling/rules_lint/tree/bazel_lib_dep
2. `cd rules_lint/example`
3. `bazel build --aspects=//tools/lint:linters.bzl%clang_tidy --output_groups=rules_lint_human src:hello_c && cat bazel-bin/src/hello_c.AspectRulesLintClangTidy.out`
4. change `bazel-lib` dep to 2.7.7 in `rules_lint/MODULE.bazel`
5. `bazel build --aspects=//tools/lint:linters.bzl%clang_tidy --output_groups=rules_lint_human src:hello_c && cat bazel-bin/src/hello_c.AspectRulesLintClangTidy.out`

Any other information?

No response

alexeagle commented 2 months ago

I guess you're using WORKSPACE and not bzlmod, since the MODULE.bazel file in this repo already has a minimum of bazel-lib 2.5.0. See #354

agoessling commented 2 months ago

I don't think so, the reproduction branch I linked above doesn't even have a WORKSPACE file, only MODULE.bazel: image

agoessling commented 2 months ago

Also note, the required dependency is >2.5.0, 2.5.0 is in the MODULE.bazel file and it doesn't work.

agoessling commented 2 months ago

@alexeagle I'm not sure this should be closed. Did you take a look at the branch that is reproducing this issue? It is using bzlmod. The issue isn't with not having 2.5.0, 2.5.0 is not enough. 2.7.7 makes it work. Note: rules_lint contains an override to 2.7.7. Sorry I haven't done a good job explaining the issue. The reproduction steps above are probably the best way to demonstrate the problem.