Skip to main content
function Runnable.command
def Runnable.command(
*,
args: list[str] = [],
env: dict[str, None | str] = …,
cwd: None | str = None
) -> std.process.Command
A std.process.Command set up the way bazel run would start this target, for callers that want to spawn it themselves. The argv is the target’s args attribute followed by args. The environment is RunEnvironmentInfo, then BUILD_WORKSPACE_DIRECTORY, BUILD_WORKING_DIRECTORY and the ASPECT_* directories, then the runfiles variables when the target has a runfiles tree, then env, where a None value removes the variable. cwd defaults to workspace_dir, the directory bazel run uses, else the directory the task was invoked from. The command spawns in its own process group, so cancelling its token stops everything it started.
property Runnable.args
Runnable.args: list[str]
The target’s args attribute, location- and make-variable-expanded and shell-tokenized the way bazel run does it. property Runnable.default_outputs
Runnable.default_outputs: list[str]
Absolute paths of every file in the target’s default output group, the executable among them. property Runnable.env
Runnable.env: list[(str, str)]
RunEnvironmentInfo.environment: the variables the rule asks to be set when the target runs. property Runnable.exec_path
Runnable.exec_path: str
The executable’s path relative to the execution root, e.g. bazel-out/k8-fastbuild/bin/pkg/tool. property Runnable.inherited_env
Runnable.inherited_env: list[str]
RunEnvironmentInfo.inherited_environment: variable names the rule asks to be passed through from the invoking environment. They are, by virtue of the process inheriting the CLI’s environment. property Runnable.label
Runnable.label: str
The target, as it was asked for. property Runnable.path
Runnable.path: str
The executable’s absolute path on disk. property Runnable.runfiles_dir
Runnable.runfiles_dir: None | str
The materialized runfiles tree, <path>.runfiles, or None when the executable has no runfiles. It exists by the time you hold this value. property Runnable.runfiles_exec_path
Runnable.runfiles_exec_path: str
The runfiles directory’s path relative to the execution root: exec_path + ".runfiles". property Runnable.runfiles_manifest
Runnable.runfiles_manifest: None | str
The input runfiles manifest Bazel wrote next to the executable, or None for an executable without runfiles support. property Runnable.tags
Runnable.tags: list[str]
The target’s tags. property Runnable.workspace_dir
Runnable.workspace_dir: None | str
runfiles_dir/<workspace_name>, the working directory bazel run starts the process in, or None without a runfiles tree. property Runnable.workspace_name
Runnable.workspace_name: str
The main repository’s name inside runfiles trees: _main under bzlmod, the WORKSPACE name otherwise.