SIGN IN SIGN UP

fix(delivery): fix executable file detection (#1157)

## Summary

**1. Runfiles directory naming.** Bazel names `<exec>.runfiles` after
the executable file artifact (including extension), see
[`RunfilesSupport.java`](https://github.com/bazelbuild/bazel/blob/9.0.0rc1/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java#L83-L84).
Detection now checks `<entrypoint>.runfiles` on disk.

**2. Pass-2 entrypoint selection extended.** A new `_SCRIPT_EXTENSIONS`
list (`.sh`, `.bash`, `.exe`, `.bat`) drives the second pass of
entrypoint selection so any of the common custom-executable extensions
resolve directly without falling through to the pass-3 first-executable
scan.

**3. `--run-in-cwd` flag (format only).** `_spawn`'s default cwd now
matches `bazel run` (`<runfiles_dir>/<workspace>`). A new `--run-in-cwd`
flag on `format` switches to the invocation cwd, mirroring Bazel's
`--run_in_cwd`. Required for targets that don't switch to
`$BUILD_WORKING_DIRECTORY` themselves — e.g.
`@buildifier_prebuilt//buildifier`, a plain symlink to the Go binary.
The `aspect buildifier` alias sets this by default.

**4. Delivery hard-fails non-runnable targets.** A target tagged
`deliverable` whose entrypoint has no runfiles tree now fails delivery
(exit 1) instead of silently warning. Pass `--warn-not-runnable` to keep
the warn-and-continue behaviour.

---

### Changes are visible to end-users: yes

- Searched for relevant documentation and updated as needed: no
- Breaking change (forces users to change their own code or config): yes
— `deliverable`-tagged targets with no runfiles tree now fail by
default; pass `--warn-not-runnable` to restore the old behaviour.
- Suggested release notes appear below: yes

`aspect delivery` now correctly delivers custom rules whose declared
output carries a file extension (`.sh`, `.bash`, etc...). `aspect
format` gains a `--run-in-cwd` flag (mirrors Bazel's `--run_in_cwd`) for
formatter targets that resolve workspace-relative arguments against
process cwd. A `deliverable`-tagged target with no runfiles tree now
hard-fails delivery; pass `--warn-not-runnable` to restore warning
behaviour.

### Test plan

- `lib/runnable_test.axl` — 40 unit tests covering pass-2 selection for
each extension and the priority order, pass-3 executable-bit filtering,
and `<entrypoint>.runfiles` filesystem detection
- `examples/deliverable/custom_deliverable.bzl` — two e2e fixtures
(`custom_deliverable` for `.sh`, `bash_deliverable` for `.bash`); both
deliver successfully in CI on Buildkite, CircleCI, and GitHub Actions
- The existing non-executable genrule fixture
(`non_executable_deliverable`) keeps CI delivery green via
`--warn-not-runnable`

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
G
Greg Magolan committed
5af7ed0079ddb123d283ae94ae6ef5b5d0741693
Parent: aaa082a
Committed by GitHub <noreply@github.com> on 5/29/2026, 9:23:39 AM