Repository rule errors are printed three times #18488
Labels
help wanted
Someone outside the Bazel team could own this
P3
We're not considering working on this, but happy to review a PR. (No assignee)
team-ExternalDeps
External dependency handling, remote repositiories, WORKSPACE file.
type: bug
Description of the bug:
When a repository rule implementation wants to report a failure, the only option right now is to use
fail(<msg>)
, but that will print the message three times in the output. Here is an example with a syntax error, but fail() invocations behave the same:The problem is that this error message is the only place to provide information about the failure. We often see messages spanning 10s or 100s of lines there from rules_nixpkgs, as the error contains the output of the underlying command. Printing it three times (four including quiet = False) scrambles the log, and is generally unhelpful.
Not sure about the proper fix, but maybe an 'error()' builtin, related to #4772 ?
Or wrapping https://github.com/bazelbuild/bazel/blob/7.0.0-pre.20230123.5/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryFunction.java#L267-L273 with an
AlreadyReportedRepositoryAccessException
?, leaving only the last one to get rid of ?My impression here is that the two backtraces are about the same, and one should go. As for the last error, it should only contain a single line summary, not the full message again.
See https://gist.github.com/layus/005db27d799612bc7cbc0ccbf4cf554d#file-output-md for more insights
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
See https://gist.github.com/layus/005db27d799612bc7cbc0ccbf4cf554d#file-output-md for a detailed MWE.
Which operating system are you running Bazel on?
Ubuntu
What is the output of
bazel info release
?7.0.0-pre.20230123.5
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.built with nix
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
https://gist.github.com/layus/005db27d799612bc7cbc0ccbf4cf554d#file-output-md
Also, a library-side improvement for readability tweag/rules_nixpkgs#389
The text was updated successfully, but these errors were encountered: