Closed philsc closed 2 years ago
Pinging code owners @brandjon and @tetromino
Hm. According to the documentation for data
,
The default outputs and runfiles of targets in the data attribute should appear in the *.runfiles area of any executable which is output by or has a runtime dependency on this target. [emphasis mine]
So you'd think since the stardoc target is used in a data
attr, adding the output md to runfiles shouldn't matter when it's already in default outputs.
Then again, the update script is not accessing these files from the runfiles tree, it's looking for the build outputs in bazel-bin/
. Still, when I look at the runfiles manifest of the update script, it only includes the update
and update.sh
executables, not the default outputs of the stardoc targets.
I do notice that the md files are absent from bazel-bin/
until I request them explicitly in a bazel invocation.
So it sounds like contrary to the documentation, sh_binary
is not populating the runfiles tree with default outputs of its targets in data
, and that this also causes them to not be built. This thwarts both the traditional way to access data files (runfiles), and the bazel-bin/
mechanism that the updater script is using.
Doing a quick search for open issues involving sh_binary
and data
, I see that this is indeed the case: bazelbuild/bazel#15043, with pending pull bazelbuild/bazel#15052.
I see no issue with working around this by having stardoc add the output to runfiles too.
You know, I've been writing explicit DefaultInfo
instances for so long that I forgot that default outputs get captured automatically (or at least should be).
Really appreciate the review. I didn't realize that this is actually a bug in bazel. Thank you!
There's currently a nuisance with the
stardoc()
rule that presents itself inrules_python
:A sample of the targets involved look like so:
The
update
target could instead reference the*.md_
files directly instead of referencing thestardoc()
targets. But it's not obvious that this is the desired work flow. It feels like users should be able to depend on thestardoc()
target instead of its predeclared output.This patch fixes this by adding the predeclared outputs to the target's runfiles. That lets the
rules_python
doc update target work again.