<#18810 `adhoc_tool` `stdout` and `stderr` are rel...
# github-notifications
c
#18810 `adhoc_tool` `stdout` and `stderr` are relative to build root, not workdir Issue created by huonw Describe the bug The
stdout
and
stderr
fields are documented as being relative to the workdir, the same as
output_files
and
output_directories
, but are currently relative to the build root: pants/src/python/pants/backend/adhoc/target_types.py Lines 147 to 166 in </pantsbuild/pants/commit/a39c1b970be2cb4421b20728c21c3222aeb4b015|a39c1b9> Reproducer, with the
output_files
version for comparison:
Copy code
cd $(mktemp -d)

cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.16.0rc1"
backend_packages = ["pants.backend.experimental.adhoc", "pants.backend.shell"]

[anonymous-telemetry]
enabled = false
EOF

mkdir -p dir/

cat > dir/BUILD <<EOF
system_binary(name="sh", binary_name="sh")
system_binary(name="tree", binary_name="tree")

adhoc_tool(
    name="via_fields",
    runnable=":sh",
    args=["-c", "echo out; echo err >&2"],
    stdout="out.txt",
    stderr="err.txt",
    workdir=".",
)

run_shell_command(
    name="via_fields_check",
    command="echo fields; tree {chroot}",
    execution_dependencies=[":via_fields"],
)

adhoc_tool(
    name="via_files",
    runnable=":sh",
    args=["-c", "echo out > out.txt; echo err > err.txt"],
    output_files=["out.txt", "err.txt"],
    workdir=".",
)

run_shell_command(
    name="via_files_check",
    command="echo files; tree {chroot}",
    execution_dependencies=[":via_files"],
)
EOF

pants run dir:via_fields_check
pants run dir:via_files_check
Output:
Copy code
fields
/private/var/folders/sv/vd266m4d4lvctgs2wpnhjs9w0000gn/T/pants-sandbox-6OvnfF
├── err.txt
└── out.txt

0 directories, 2 files
files
/private/var/folders/sv/vd266m4d4lvctgs2wpnhjs9w0000gn/T/pants-sandbox-fzWIGm
└── dir
    ├── err.txt
    └── out.txt

1 directory, 2 files
The bug is that the
fields
version is at the top level of the chroot: it should match the
files
version, being within
dir/
. Pants version 2.16.0rc1 OS macOS Additional info N/A pantsbuild/pants