bazelbuild / bazelbuild/bazel

Provide a way to redirect stdout/stderr into a file

Open
#5,511 43 comments 53 reactions 0 assignees View on GitHub
not stale P3 team-Rules-API type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the problem / feature request:

It is common for programs in unix world to output the result of an invocation to stdout. The current way to capture that output is to either use `ctx.actions.run_shell()` or a wrapping shell script to redirect it to a file. This requires spawning an extra process and hence adds some overhead. Perhaps it makes sense to provide a way for `ctx.actions.run()` to redirect stdout and/or stderr into a file.

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

I have a tool that does what I described above - writes the result of its invocation to stdout. I need to capture that output and put it into a file - it is the output of the rule. Currently I have to wrap it in a shell script and I thought it might be good to suggest this feature. Thanks.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing ctx.actions.run() and ctx.actions.run_shell() entry points and the issue discussion about capturing stdout and stderr. Define the intended redirection behavior and API before implementing it, then verify that the requested output can be captured without a wrapping shell process.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.