Bazel: add quiet mode to bazel run

Created on 16 Mar 2018  Â·  8Comments  Â·  Source: bazelbuild/bazel

Description of the problem / feature request:

bazel run always prints out a few INFO log messages before running the command, and there seems to be no way of suppressing that output.

For example, I want to suppress all of these INFO: lines when running the following in kuberentes/kubernetes:

$ bazel run  --show_result=0 --noshow_progress --noshow_loading_progress --logging=0 cmd/kubectl -- version --client
INFO: Analysed target //cmd/kubectl:kubectl (589 packages loaded).
INFO: Found 1 target...
INFO: Elapsed time: 79.858s, Critical Path: 39.71s

INFO: Running command line: bazel-bin/cmd/kubectl/linux_amd64_pure_stripped/kubectl version
Client Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0-alpha.0.1096+05ae431ea0978e", GitCommit:"05ae431ea0978ee2fc0be91e5b9bc82feb97b3a2", GitTreeState:"clean", BuildDate:"2018-03-16T22:46:18Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

Feature requests: what underlying problem are you trying to solve with this feature?

I'd like to be able to build and run binaries through bazel without any additional information being written to stderr/stdout, since the tool being run also prints to stderr/stdout.

What operating system are you running Bazel on?

Linux

What's the output of bazel info release?

release 0.11.1

Have you found anything relevant by searching the web?

Found a related discussion in https://groups.google.com/forum/#!topic/bazel-discuss/JVCotYRXeyk.
I couldn't find any feature requests filed after @ulfjack's last reply there.

team-XProduct feature request untriaged

Most helpful comment

$ bazel run --experimental_ui_limit_console_output=1 hello-world
Hello world

Unfortunately, it looks like setting it to 0 means no limit.

All 8 comments

Agree that this would be nice to have.

Realistically, I won't have time to work on this in the next months, even though this should not be a huge change.

@ixdy Is the --script_path flag a possible workaround for your usecase?

@philwo to me it looks like a bug that the run command is not respecting the --logging flag. For example even with --logging=0, bazel run still produces INFO logging information. From looking at the code it appears we need more filtering options in the build event handler.

And for us --script_path is not really a work around because it does not force a rebuild. We are trying to go for a system where you don't explicitly build anything you always use a bazal command, but that is hampered by the noise generated here.

The --logging flag isn't related to the command-line output, but to
internal logging.

On Tue, Sep 11, 2018 at 6:04 PM Joseph Lisee notifications@github.com
wrote:

@philwo https://github.com/philwo to me it looks like a bug that the run
command not respecting the --logging flag
https://github.com/bazelbuild/bazel/blob/3c5a109/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java#L72.
For example even with --logging=0, bazel run still produces INFO logging
information. From looking at the code
https://github.com/bazelbuild/bazel/blob/56d125b9a4c8bf9a18bb83e473bc07759c708087/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
it appears we need more filtering options in the build event handler.

And for us --script_path is not really a work around because it does not
force a rebuild. We are trying to go for a system where you don't
explicitly build anything you always use a bazal command, but that is
hampered by the noise generated here.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/bazel/issues/4867#issuecomment-420327324,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHA9YZIGv2lJPJj40hYv-3BaSfVpCmJ4ks5uZ98ggaJpZM4SuiR3
.

Have any new workarounds been found since last year for this?

$ bazel run --experimental_ui_limit_console_output=1 hello-world
Hello world

Unfortunately, it looks like setting it to 0 means no limit.

@ulfjack Is there a way to use experimental_ui_limit_console_output but still expect errors to be printed? I've also tried bazel run //:target > /dev/null without any luck

No, unfortunately not. It limits all output, not just info messages. Bazel 3.3.0 has commit 7c67d1ddf7b6db608e86f2e5a915fb8687101f5f, which adds --ui_event_filters. Maybe try that?

Hey, just wanted to share the option I've gone with to invoke CLI tools build via Bazel:

#!/usr/bin/env bash
bazel build //target:target &> /dev/null
bazel-bin/target:target $@
Was this page helpful?
0 / 5 - 0 ratings