stardoc icon indicating copy to clipboard operation
stardoc copied to clipboard

Stardoc build fails unless you test first

Open keith opened this issue 3 years ago • 4 comments

On rules apple, when attempting to build documentation it fails:

% bazel clean --expunge
...
% bazel build doc/...
INFO: Analyzed 21 targets (0 packages loaded, 0 targets configured).
INFO: Found 21 targets...
ERROR: /Users/ksmiley/dev/rules_apple/doc/BUILD.bazel:28:12: Generating proto for Starlark doc for tvos.doc_doc failed: (Exit 1): stardoc failed: error executing command bazel-out/host/bin/external/io_bazel_stardoc/stardoc/stardoc '--input=//apple:tvos.doc.bzl' '--workspace_name=build_bazel_rules_apple' '--dep_roots=.' '--dep_roots=external/build_bazel_rules_apple' ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
com.google.devtools.build.skydoc.SkydocMain$StarlarkEvaluationException: File apple/internal/tvos_rules.bzl imported '@build_bazel_rules_apple//apple/internal/aspects:swift_dynamic_framework_aspect.bzl', yet apple/internal/aspects/swift_dynamic_framework_aspect.bzl was not found, even at roots [., external/build_bazel_rules_apple].
        at com.google.devtools.build.skydoc.SkydocMain.recursiveEval(SkydocMain.java:412)
        at com.google.devtools.build.skydoc.SkydocMain.recursiveEval(SkydocMain.java:402)
        at com.google.devtools.build.skydoc.SkydocMain.eval(SkydocMain.java:260)
        at com.google.devtools.build.skydoc.SkydocMain.main(SkydocMain.java:163)
Caused by: java.nio.file.NoSuchFileException: apple/internal/aspects/swift_dynamic_framework_aspect.bzl
        at com.google.devtools.build.skydoc.SkydocMain.getInputSource(SkydocMain.java:454)
        at com.google.devtools.build.skydoc.SkydocMain.recursiveEval(SkydocMain.java:385)
        at com.google.devtools.build.skydoc.SkydocMain.recursiveEval(SkydocMain.java:402)
        ... 3 more
Stardoc documentation generation failed: File apple/internal/tvos_rules.bzl imported '@build_bazel_rules_apple//apple/internal/aspects:swift_dynamic_framework_aspect.bzl', yet apple/internal/aspects/swift_dynamic_framework_aspect.bzl was not found, even at roots [., external/build_bazel_rules_apple].
INFO: Elapsed time: 1.681s, Critical Path: 1.46s
INFO: 10 processes: 10 internal.
FAILED: Build did NOT complete successfully

If you instead run some diff_test targets that depend on the docs, they pass:

% bazel test doc/...
INFO: Build option --test_env has changed, discarding analysis cache.
INFO: Analyzed 9 targets (0 packages loaded, 687 targets configured).
INFO: Found 9 test targets...
INFO: Elapsed time: 5.168s, Critical Path: 4.68s
INFO: 28 processes: 36 local.
INFO: Build completed, 1 test FAILED, 28 total actions
//doc:check_dtrace                                                       PASSED in 0.6s
//doc:check_ios.doc                                                      PASSED in 0.5s
//doc:check_macos.doc                                                    PASSED in 0.5s
//doc:check_providers                                                    PASSED in 0.2s
//doc:check_resources                                                    PASSED in 0.3s
//doc:check_tvos.doc                                                     PASSED in 0.4s
//doc:check_versioning                                                   PASSED in 0.4s
...

and then subsequent builds are successful:

% bazel build doc/...
INFO: Build option --test_env has changed, discarding analysis cache.
INFO: Analyzed 21 targets (0 packages loaded, 691 targets configured).
INFO: Found 21 targets...
INFO: Elapsed time: 0.339s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

keith avatar Oct 21 '21 20:10 keith

Hmm, very strange. I get a different error along the same lines:

$ bazelisk build doc/...
INFO: Analyzed 22 targets (0 packages loaded, 0 targets configured).
INFO: Found 22 targets...
ERROR: /Users/arostovtsev/bazelbuild/rules_apple/doc/BUILD.bazel:28:12: Generating proto for Starlark doc for resources_doc failed: (Exit 1): stardoc failed: error executing command bazel-out/host/bin/external/io_bazel_stardoc/stardoc/stardoc '--input=//apple:resources.bzl' '--workspace_name=build_bazel_rules_apple' '--dep_roots=.' '--dep_roots=external/build_bazel_rules_apple' ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
com.google.devtools.build.skydoc.SkydocMain$StarlarkEvaluationException: File external/rules_cc/cc/defs.bzl imported '//cc/private/rules_impl:cc_flags_supplier.bzl', yet external/rules_cc/cc/private/rules_impl/cc_flags_supplier.bzl was not found, even at roots [., external/build_bazel_rules_apple].
	at com.google.devtools.build.skydoc.SkydocMain.recursiveEval(SkydocMain.java:412)
	at com.google.devtools.build.skydoc.SkydocMain.recursiveEval(SkydocMain.java:402)
	at com.google.devtools.build.skydoc.SkydocMain.eval(SkydocMain.java:260)
	at com.google.devtools.build.skydoc.SkydocMain.main(SkydocMain.java:163)
Caused by: java.nio.file.NoSuchFileException: external/rules_cc/cc/private/rules_impl/cc_flags_supplier.bzl
	at com.google.devtools.build.skydoc.SkydocMain.getInputSource(SkydocMain.java:454)
	at com.google.devtools.build.skydoc.SkydocMain.recursiveEval(SkydocMain.java:385)
	at com.google.devtools.build.skydoc.SkydocMain.recursiveEval(SkydocMain.java:402)
	... 3 more
Stardoc documentation generation failed: File external/rules_cc/cc/defs.bzl imported '//cc/private/rules_impl:cc_flags_supplier.bzl', yet external/rules_cc/cc/private/rules_impl/cc_flags_supplier.bzl was not found, even at roots [., external/build_bazel_rules_apple].
INFO: Elapsed time: 2.470s, Critical Path: 2.03s
INFO: 10 processes: 9 internal, 1 darwin-sandbox.
FAILED: Build did NOT complete successfully

But the error makes no sense: $(bazelisk info execution_root)/external/rules_cc/cc/private/rules_impl/cc_flags_supplier.bzl exists.

tetromino avatar Oct 22 '21 18:10 tetromino

Yea I think there's some racing with the errors so I've seen multiple as well

keith avatar Oct 22 '21 18:10 keith

FWIW, I've tried regenerating Stardoc's bundled jars at https://github.com/bazelbuild/bazel/commit/15a093928141cd6d06ba6db3cd9ab46f33412c07 (release 5.0.0-pre.20211011.2) and I am still seeing the same error.

tetromino avatar Oct 25 '21 18:10 tetromino

Looks like disabling sandboxing avoids this https://github.com/bazelbuild/rules_apple/pull/1255 so maybe some input isn't correctly defined?

keith avatar Oct 29 '21 17:10 keith