mdbook preprocessor written as a `py_binary` is silently skipped
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- build-system
Research direction
Start with the mdbook rule loaded from @rules_rust_mdbook//:defs.bzl and trace how the plugins attribute handles the py_binary target and its executable. Reproduce the issue with the provided MODULE.bazel, BUILD.bazel, book.toml, and sample files; done means the preprocessor expands {{secret}} to 42 and the build output reflects the expansion.
Written by the indexing model from the issue text.
Description
Description
I have an mdbook target whose preprocessor is a py_binary listed in plugins. The build succeeds, but the preprocessor never runs: the marker it should expand is left unchanged, and nothing appears in the build log to say so.
Reproduction steps
MODULE.bazel
module(name = "repro", version = "0.0.0")
bazel_dep(name = "rules_rust_mdbook", version = "0.73.0")
bazel_dep(name = "rules_python", version = "2.2.0")
BUILD.bazel
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_rust_mdbook//:defs.bzl", "mdbook")
py_binary(
name = "mdbook_secret",
srcs = ["mdbook_secret.py"],
data = ["secret.txt"],
)
mdbook(
name = "book",
srcs = glob(["src/**/*.md"]),
book = "book.toml",
plugins = [":mdbook_secret"],
)
book.toml
[book]
title = "Plugin Runfiles Repro"
src = "src"
[preprocessor.secret]
command = "mdbook_secret"
mdbook_secret.py
#!/usr/bin/env python3
"""Replaces {{secret}} with the contents of a data file."""
import json
import sys
from pathlib import Path
SECRET = Path(__file__).parent / "secret.txt"
def main() -> None:
if len(sys.argv) > 1 and sys.argv[1] == "supports":
sys.exit(0)
secret = SECRET.read_text().strip()
_context, book = json.load(sys.stdin)
for section in book["sections"]:
chapter = section.get("Chapter")
if chapter:
chapter["content"] = chapter["content"].replace("{{secret}}", secret)
print(json.dumps(book))
if __name__ == "__main__":
main()
secret.txt
42
src/SUMMARY.md
# Summary
- [Chapter 1](./chapter_1.md)
src/chapter_1.md
# Chapter 1
The secret is: {{secret}}.
Then:
$ bazel build //:book
INFO: Build completed successfully
$ grep -o "The secret is: [^<]*" bazel-bin/book/chapter_1.html
The secret is: {{secret}}.
Bazel and rules_rust version
Bazel version: 8.7.0
rules_python version 2.2.0
rules_rust_mdbook version: 0.73.0
- Dominant language
- Starlark
- Stars
- 857
- Forks
- 701
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 46
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bazelbuild/rules_rust
-
`rust_test(crate = ...)` does not stage the crate's transitive dynamic libraries into runfilesPossibly taken @Wito-1 claimed this 65 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
bazelbuild/rules_rust#4309 ·
Maintainers usually reply within 3 days
-
Windows (no-symlink path): drain_runfiles_dir_windows deletes retained runfiles — inverted filename_suffixes_to_retain conditionPossibly taken @Mattbusel claimed this 17 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
bazelbuild/rules_rust#4266 ·
Maintainers usually reply within 3 days
-
rust.toolchain(strip_level = ...) is silently ignoredPossibly taken @Mattbusel claimed this 17 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
bazelbuild/rules_rust#4223 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
bazelbuild/rules_rust#4152 · 1 reaction ·
Maintainers usually reply within 3 days
-
awaiting-response
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bazelbuild/rules_rust#3599 · 1 comment ·
Maintainers usually reply within 3 days
All issues in bazelbuild/rules_rust
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
bazelbuild/apple_support#707 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
out-of-date
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
CachyOS/CachyOS-PKGBUILDS#2232 ·
Maintainers usually reply within 1 day
-
blast/large refactor risk/low spend-dem
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
chriskelly/MusicWall#87 · 2 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
neilotoole/sq#1503 ·
Maintainers usually reply within 1 day