-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Bzlmod: stardoc is broken by repo mappings #14140
Description
When Bzlmod is enabled, building stardoc for a bzl_library which has external dependencies will fail.
This is discovered in bazelbuild/bazel-central-registry#18, and the build failure can be found here.
The root cause is that when Bzlmod is enabled, the canonical repo name for bazel_skylib is bazel_skylib.1.0.3, which now contains the version number. In the normal bazel build, we have repo mappings to make sure BUILD/bzl files can still access the targets under the repository with @bazel_skylib. However, when stardoc is parsing a label, it's not doing any repo mapping to locate the canonical repo name. Which led to:
Stardoc documentation generation failed: File external/io_bazel_stardoc.0.5.0/stardoc/stardoc.bzl imported '@bazel_skylib//:bzl_library.bzl', yet external/bazel_skylib/bzl_library.bzl was not found, even at roots [., external/__main__].
Note that this is also an issue if you use the repo mapping feature in WORKSPACE file, but it's not widely used so no one has hit this problem before. Since we are embracing the repo mapping feature in Bzlmod to avoid conflicts and provide strict deps, we have to solve this problem.
Related #13316