Replace mapfile with a bash 3.2-safe loop in cache-key.sh #1

Merged
stephen merged 2 commits from fix-bash32-mapfile into main 2026-06-02 03:32:43 +00:00
Owner

On a macOS runner this action's cache cargo step died with:

scripts/cache-key.sh: line 73: mapfile: command not found

cache-key.sh runs under set -euo pipefail and used mapfile, a bash 4+ builtin. macOS ships bash 3.2, which has no mapfile, so the step exited 127. The Linux CI runner's newer bash hid it (same situation as the setup-rust-action bash 3.2 fix).

Reads the sorted/de-duped lock paths with a portable while read loop instead, guards the array expansions for the empty case under set -u, and adds a static check to the suite that mapfile/readarray don't return. Verified: the suite passes under /bin/bash 3.2, and a direct 3.2 run yields 0 entries for empty input and correct de-dup for populated input.

After merge this needs v1.0.1 cut and v1 moved so @v1 consumers pick it up.

On a macOS runner this action's `cache cargo` step died with: ``` scripts/cache-key.sh: line 73: mapfile: command not found ``` `cache-key.sh` runs under `set -euo pipefail` and used `mapfile`, a bash 4+ builtin. macOS ships **bash 3.2**, which has no `mapfile`, so the step exited 127. The Linux CI runner's newer bash hid it (same situation as the setup-rust-action bash 3.2 fix). Reads the sorted/de-duped lock paths with a portable `while read` loop instead, guards the array expansions for the empty case under `set -u`, and adds a static check to the suite that `mapfile`/`readarray` don't return. Verified: the suite passes under `/bin/bash` 3.2, and a direct 3.2 run yields 0 entries for empty input and correct de-dup for populated input. After merge this needs `v1.0.1` cut and `v1` moved so `@v1` consumers pick it up.
Replace mapfile with a bash 3.2-safe loop in cache-key.sh
Some checks failed
test / unit (pull_request) Successful in 5s
test / e2e (pull_request) Failing after 20s
3cc02166e2
`cache-key.sh` runs under `set -euo pipefail` and used `mapfile`, a bash
4+ builtin. macOS ships bash 3.2, so on a macOS runner the step died with
`mapfile: command not found` (exit 127). The Linux CI runner's newer bash
hid it.

Read the sorted/de-duped lock paths with a portable `while read` loop,
guard the array expansions for the empty case under `set -u`, and add a
static check to the suite that mapfile/readarray don't creep back in.
ci: install rust via setup-rust-action in the e2e job
All checks were successful
test / unit (pull_request) Successful in 4s
test / e2e (pull_request) Successful in 15s
24fcdbd365
The e2e job assumed `rustc`/`rustup` already existed on the runner
(`rustc --version || rustup default stable`), but the bare Linux runner
has neither, so the job failed with `rustup: command not found` (this was
already red on main, independent of the mapfile fix). Install a toolchain
with setup-rust-action (pinned to v1.0.1) before seeding the crate.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rasterstate/rust-cache-action!1
No description provided.