Skip to main content
Version: 2.20 (deprecated)

run_shell_command


Run a script in the workspace, with all dependencies packaged/copied into a chroot.

Example BUILD file:

run_shell_command(
command="./scripts/my-script.sh --data-files-dir={chroot}",
execution_dependencies=["src/project/files:data"],
)

The command may use either {chroot} on the command line, or the $CHROOT environment variable to get the root directory for where any dependencies are located.

In contrast to the shell_command, in addition to workdir you only have the command and execution_dependencies fields as the tools you are going to use are already on the PATH which is inherited from the Pants environment. Also, the outputs does not apply, as any output files produced will end up directly in your project tree.

Backend: pants.backend.shell


command

str
required

Shell command to execute.

The command is executed as 'bash -c <command>' by default. If you want to invoke a binary use exec -a $0 <binary> <args> as the command so that the binary gets the correct argv[0] set.

description

str | None
default: None

A human-readable description of the target.

Use pants list --documented :: to see all targets with descriptions.

execution_dependencies

Iterable[str] | None
default: None

The execution dependencies for this command.

Dependencies specified here are those required to make the command complete successfully (e.g. file inputs, packages compiled from other targets, etc), but NOT required to make the outputs of the command useful.

See also runnable_dependencies.

runnable_dependencies

Iterable[str] | None
default: None

The runnable dependencies for this command.

Dependencies specified here are those required to exist on the PATH to make the command complete successfully (interpreters specified in a #! command, etc). Note that these dependencies will be made available on the PATH with the name of the target.

See also execution_dependencies.

tags

Iterable[str] | None
default: None

Arbitrary strings to describe a target.

For example, you may tag some test targets with 'integration_test' so that you could run pants --tag='integration_test' test :: to only run on targets with that tag.

workdir

str | None
default: '.'

Sets the working directory for the process.

Values are relative to the build root, except in the following cases:

  • . specifies the location of the BUILD file.
  • Values beginning with ./ are relative to the location of the BUILD file.
  • / or the empty string specifies the build root.
  • Values beginning with / are also relative to the build root.