bazel-contrib / rules_fuzzing

Bazel Starlark extensions for defining fuzz tests in Bazel projects
Apache License 2.0
87 stars 20 forks source link

Latest version of rules_fuzzing (0.5.2) introduces dependency cycle #252

Open xansec opened 2 months ago

xansec commented 2 months ago

Expected Behavior

rules_fuzzing works as expected.

Actual Behavior

When I try to include the latest version (0.5.2), I get the following error:

ERROR: Failed to load Starlark extension '@@rules_python_internal//:rules_python_config.bzl'.
Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
 - @@rules_python_internal
This could either mean you have to add the '@@rules_python_internal' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.
ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping

Reverting to 0.4.2 resolves the issue.

Steps to Reproduce the Problem

  1. Create a simple fuzz target.
  2. Include with :
http_archive(
    name = "rules_fuzzing",
    strip_prefix = "rules_fuzzing-0.5.2",
    urls = ["https://github.com/bazelbuild/rules_fuzzing/releases/download/v0.5.2/rules_fuzzing-0.5.2.zip"],
)
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
rules_fuzzing_dependencies()
load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
rules_fuzzing_init()
load("@fuzzing_py_deps//:requirements.bzl", "install_deps")
install_deps()
  1. Run bazel build --config=libfuzzer <target>

Specifications

xansec commented 2 months ago

As a note - if you use bzlmod instead of your workspace file, this works fine:

MODULE.bazel

...
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
bazel build --config=libfuzzer //fuzz:all 
Starting local Bazel server and connecting to it...
WARNING: Ignoring toolchain 'python_3_11' from module 'rules_python': Toolchain 'python_3_11' from module 'rules_fuzzing' already registered Python version 3.11 and has precedence
INFO: Analyzed 2 targets (86 packages loaded, 4260 targets configured).
INFO: Found 2 targets...
INFO: Elapsed time: 9.778s, Critical Path: 0.82s
INFO: 20 processes: 16 internal, 4 local.
INFO: Build completed successfully, 20 total actions

My guess is bzlmod is able to handle this while WORKSPACE isn't?