Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add quiet mode to bazel run #4867

Closed
ixdy opened this issue Mar 16, 2018 · 17 comments
Closed

add quiet mode to bazel run #4867

ixdy opened this issue Mar 16, 2018 · 17 comments
Assignees
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: feature request

Comments

@ixdy
Copy link
Contributor

ixdy commented Mar 16, 2018

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.

@philwo philwo added type: feature request P3 We're not considering working on this, but happy to review a PR. (No assignee) labels Mar 21, 2018
@philwo
Copy link
Member

philwo commented Mar 21, 2018

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?

@jlisee
Copy link
Contributor

jlisee commented Sep 11, 2018

@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.

@ulfjack
Copy link
Contributor

ulfjack commented Sep 11, 2018 via email

@atavakoliyext
Copy link

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

@ulfjack
Copy link
Contributor

ulfjack commented Oct 28, 2019

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

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

bazel-io pushed a commit that referenced this issue May 7, 2020
At the moment there is not an option to easily control the verbosity of Bazel UI. The `ui_event_filters` option allows to arbitrarily filter events from the UI. The syntax is the same as `build_tag_filters` or `output_group`, so it is possible to add or remove events, using leading `+/-`, or override the default set completely with direct assignment.

Related: #4867

Closes #10936.

PiperOrigin-RevId: 310417852
@meisterT meisterT added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) category: misc > misc labels May 16, 2020
@jathu
Copy link

jathu commented Jun 24, 2020

@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

@ulfjack
Copy link
Contributor

ulfjack commented Jun 24, 2020

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

@peter-db
Copy link

peter-db commented Dec 7, 2020

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 $@

@philwo philwo added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Feb 8, 2021
@bduffany
Copy link
Contributor

bduffany commented Mar 10, 2021

Beware that @peter-db 's approach means you will lose args specified in the BUILD file. This might be fixed by adding a call to buildozer 'print args' //target:target and prepending those to the arguments there, but that approach doesn't work in 100% of cases (e.g. if a macro adds the args).

edit: a more complete fix is to use --script_path as mentioned earlier on in the thread:

#!/usr/bin/env bash
set -e
# Make a temp dir for this script.
tempdir="$(mktemp -d)"
# Generate a script containing the commands that bazel run *would* execute.
# Write build logs to a file (not the terminal), and if the build fails,
# *then* show the output from the file.
bazel run //foo --script_path="$tempdir/script.sh" &>"$tempdir/build.log" || {
  cat "$tempdir/build.log" >&2
  exit 1
}
# Run the script, forwarding extra args.
chmod +x "$tempdir/script.sh"
exec "$script" "$@"

@acecilia
Copy link

acecilia commented Apr 30, 2021

Seems like this issue is solved by ui_event_filters, no?

bazel run --ui_event_filters=-info,-stdout,-stderr --noshow_progress ...

Related: #12831 (comment)

@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 29, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2023
@luispadron
Copy link
Contributor

I feel like this is still not working correctly, if I set the following flags:

  --ui_event_filters=-info,-debug,-warning,-stderr,-stdout
  --noshow_progress
  --logging=0

I still see debug logs when the server is shutdown:

Starting local Bazel server and connecting to it...

@luispadron luispadron reopened this Oct 24, 2023
@acecilia
Copy link

Yep, there are some logs still left (maybe that is the only one?)

@github-actions github-actions bot removed the stale Issues or PRs that are stale (no activity for 30 days) label Oct 25, 2023
@jacky8hyf
Copy link

I also occasionally see "Extracting Bazel installation...". Is there any way to suppress this log and "Starting local Bazel server and connecting to it..."?

I have the following:

common:silent --noshow_progress
common:silent --ui_event_filters=,+error,+fail
common:silent --show_result=0
common:silent --logging=0

@lberki
Copy link
Contributor

lberki commented Oct 14, 2024

Update: I'm cooking a change for this. It's Google-internal because it turns out that it requires quite a bit of refactoring in the client to suppress the Extracting Bazel installation... messages and we have one pretty annoying integration point at Google that uses the C++ code of the Bazel client.

The interface will be bazel --quiet <command> <command arguments>. This must be a startup option so that it can affect the Bazel client, and thus the "Extracting..." messages.

copybara-service bot pushed a commit that referenced this issue Oct 17, 2024
Finishing touches for #4867.

RELNOTES: None.
PiperOrigin-RevId: 686819148
Change-Id: I9ff2424683b8579ad5a953f7974c9579c5e715db
lberki added a commit that referenced this issue Oct 17, 2024
This change adds a "--quiet" startup option, which causes Blaze not to print any status messages, progress messages, info messages or warnings of any kind. Error messages are still emitted as usual.

Fixes #4867.

RELNOTES[NEW]: The "blaze --quiet" command line option can now be used to make Blaze emit much less output.

PiperOrigin-RevId: 686784300
Change-Id: Ibaa0b6a1788b43863337dce6fc16da09defb6724
lberki added a commit that referenced this issue Oct 17, 2024
Finishing touches for #4867.

RELNOTES: None.
PiperOrigin-RevId: 686819148
Change-Id: I9ff2424683b8579ad5a953f7974c9579c5e715db
github-merge-queue bot pushed a commit that referenced this issue Oct 17, 2024
Implement "quiet mode"
This change adds a "--quiet" startup option, which causes Blaze not to
print any status messages, progress messages, info messages or warnings
of any kind. Error messages are still emitted as usual.

Fixes #4867.

RELNOTES[NEW]: The "blaze --quiet" command line option can now be used
to make Blaze emit much less output.

PiperOrigin-RevId: 686784300
Change-Id: Ibaa0b6a1788b43863337dce6fc16da09defb6724
copybara-service bot pushed a commit that referenced this issue Oct 22, 2024
Rearguard fighting for #4867.

RELNOTES: None.
PiperOrigin-RevId: 688453143
Change-Id: I3f5a2f3f69676b5c5d6941b25b0d4c35a06e6056
lberki added a commit that referenced this issue Oct 22, 2024
Rearguard fighting for #4867.

RELNOTES: None.
PiperOrigin-RevId: 688453143
Change-Id: I3f5a2f3f69676b5c5d6941b25b0d4c35a06e6056
github-merge-queue bot pushed a commit that referenced this issue Oct 22, 2024
Rearguard fighting for #4867.

RELNOTES: None.
PiperOrigin-RevId: 688453143
Change-Id: I3f5a2f3f69676b5c5d6941b25b0d4c35a06e6056
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 8.0.0 RC2. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=8.0.0rc2. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: feature request
Projects
None yet
Development

No branches or pull requests