Skip to content

Bzlmod: stardoc is broken by repo mappings #14140

@meteorcloudy

Description

@meteorcloudy

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

Metadata

Metadata

Labels

P2We'll consider working on this in future. (Assignee optional)area-BzlmodBzlmod-specific PRs, issues, and feature requeststeam-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.type: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions