Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see Bazel build output?

Tags:

bazel

How do you view stdout of bazel build as it happens?

I want to see all the logs written to stdout during a bazel build.

No one of these allows it to show the ls command before after it has failed

$ bazel build --show_progress --worker_verbose --verbose_failures --verbose_explanations=true -s --test_output=streamed :build
genrule(
  name = "build",
  cmd = "ls && sleep 60 && exit 1",
)

$ bazel build --show_progress --worker_verbose --verbose_failures --verbose_explanations=true -s --test_output=streamed :build
WARNING: --verbose_explanations has no effect when --explain=<file> is not enabled
INFO: Analyzed target //:build (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //:build [action 'Executing genrule //:build']
(cd /private/var/tmp/_bazel_kevinsimper/f9e6a72c146c5ad83b84a8ebf539f8b2/execroot/__main__ && \
  exec env - \
    PATH=/usr/local/sbin \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; ls && sleep 60 && exit 1')
ERROR: /Users/kevinsimper/testproject/BUILD:1:1: Executing genrule //:build failed (Exit 1)
BUILD
TESTFILE
Target //:build failed to build
INFO: Elapsed time: 60.256s, Critical Path: 60.04s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
like image 985
Kevin Simper Avatar asked Sep 20 '19 07:09

Kevin Simper


People also ask

How do you run after Bazel build?

To run Bazel, go to your base workspace directory or any of its subdirectories and type bazel . % bazel help [Bazel release bazel-<version>] Usage: bazel <command> <options> ... Available commands: analyze-profile Analyzes build profile data. aquery Executes a query on the post-analysis action graph.

What is build file in Bazel?

A BUILD file contains several different types of instructions for Bazel. The most important type is the build rule, which tells Bazel how to build the desired outputs, such as executable binaries or libraries.

How does Bazel build work?

Bazel build process When running a build or a test, Bazel does the following: Loads the BUILD files relevant to the target. Analyzes the inputs and their dependencies, applies the specified build rules, and produces an action graph. Executes the build actions on the inputs until the final build outputs are produced.


1 Answers

There's no way to stream action stdout/stderr while it's executing, unless it's a test while using the --test_output=streamed flag.

like image 132
Jin Avatar answered Oct 03 '22 10:10

Jin