-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bzlmod: stardoc is broken by repo mappings #14140
Comments
Ah, I also filed bazelbuild/stardoc#117 about this |
Is there a runfiles library for Java? I think @fmeum also had a rules_runfiles or something. (Sorry I've never really looked into runfiles) That's probably the best way to resolve this. |
The runfiles library at |
Yeah Stardoc needs to convert a label into a runfile path (runtime path of a runfile?) and that's not so simple with repo mappings. |
Update: We're considering solving this in a similar fashion to #15029, by outputting a file containing all repo mappings and having that file available to binaries at runtime. It's still to be decided where this file should live. |
cc: @aiuto |
It's slightly worse. It needs to convert it to execpath. There are no runfiles (because render is packed separately than input .bzl files), and no repo_mapping because of this. |
@comius I formated an alternative idea in https://github.com/bazelbuild/proposals/blob/main/designs/2022-07-21-locating-runfiles-with-bzlmod.md#4-make-stardoc-compatible-with-repository-mappings, do you think that could work? @tetromino is working on a rewrite of some parts of stardoc that would allow it to request bzl files from Skyframe (if I understood him correctly), which should also solve this issue. |
Yes, that works. I was thinking of a slight alternative where macro would add a custom Second alternative option is to add repository mapping information to |
The custom StardocMain binary sounds better, yes. I am not so sure you can actually collect the apparent names because the rule implementation typically only sees the canonical names. But even if you could, reusing the existing repository mapping logic even if by a small hack seems more reliable to me. @tetromino Can you estimate when you would get to work on the improved bzl loading for Stardoc? Would the changes require a new Bazel version or could they be used independentl |
- Clean house: - Remove all conditional dependency code. - Remove the ability to build buildtools from source. Just use `keith/buildifier-prebuilt`. - Remove unused `binary_pkg`. - Add `MODULE.bazel` with all dependencies. - Update all example workspaces to include a `MODULE.bazel`. - Add `--noenable_bzlmod` to `shared.bazelrc` until bazelbuild/bazel#14140 is fixed. Related to #195.
- Add `WORKSPACE.bzlmod` to all workspaces to ensure that the strict bzlmod support was enabled. - Disable all documentation generation and tests until bazelbuild/bazel#14140 is fixed. - Update CI to execute tidy and test with and without bzlmod. - Fix warning in `sorted_genquery.bzl`. Related to #195.
@comius Saw the merge, thanks for that! Maybe we should keep this issue open until there is a BCR release of stardoc with the changes? |
By taking in .bzl files as runfiles rather than inputs, Stardoc can use the existing Java runfiles library to resolve apparent repository names in load labels into canonical repository names. Work towards bazelbuild#16124 Fixes bazelbuild#14140 Closes bazelbuild#16775. PiperOrigin-RevId: 526976752 Change-Id: I0848a5c7590348f778ad8c939fd37c89a53e55b2
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:
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
The text was updated successfully, but these errors were encountered: