scripts/apply-ggml-patches.sh fails on macOS:
scripts/apply-ggml-patches.sh: line 56: mapfile: command not found
The line is:
mapfile -d '' patched_paths < <(GIT_INDEX_FILE="${expected_index}" git -C "${GGML}" diff --cached --name-only -z HEAD)
mapfile is a bash 4.0 builtin. macOS ships bash 3.2.57 as /bin/bash and does not ship a newer one; GitHub's macos-* runner images list only Bash 3.2.57(1)-release, with no Homebrew bash preinstalled. The script's #!/usr/bin/env bash therefore resolves to 3.2 there and the script aborts. (mapfile -d additionally requires bash 4.4, so even a bash 4.0 or 4.2 host would fail on the delimiter flag.)
Nothing else in the script needs bash 4. A portable replacement for that one line:
patched_paths=()
while IFS= read -r -d '' path; do
patched_paths+=("${path}")
done < <(GIT_INDEX_FILE="${expected_index}" git -C "${GGML}" \
diff --cached --name-only -z HEAD)
This is bash 3.2 compatible and preserves the NUL-delimited handling, so paths containing spaces or newlines are still safe.
Worth noting that this affects macOS users even though the patch series is CUDA-only: the script is reachable from a normal build setup flow, so a macOS user hits it before reaching the point where NEMO_SPEECH_GGML_PATCHED=OFF would make the series irrelevant.
Context
Found while packaging NeMo-Speech.cpp as a backend for LocalAI (pin 2e12e2def8a98ed06666f7ee3ca94e7193e04be4). We worked around it downstream by skipping the script on Darwin and configuring with -DNEMO_SPEECH_GGML_PATCHED=OFF, which matches what the metal-* CMake presets already do by inheriting cpu-*. The script still seems worth fixing for anyone who runs it directly.
Happy to send a PR if that is useful.
scripts/apply-ggml-patches.shfails on macOS:The line is:
mapfileis a bash 4.0 builtin. macOS ships bash 3.2.57 as/bin/bashand does not ship a newer one; GitHub'smacos-*runner images list onlyBash 3.2.57(1)-release, with no Homebrew bash preinstalled. The script's#!/usr/bin/env bashtherefore resolves to 3.2 there and the script aborts. (mapfile -dadditionally requires bash 4.4, so even a bash 4.0 or 4.2 host would fail on the delimiter flag.)Nothing else in the script needs bash 4. A portable replacement for that one line:
This is bash 3.2 compatible and preserves the NUL-delimited handling, so paths containing spaces or newlines are still safe.
Worth noting that this affects macOS users even though the patch series is CUDA-only: the script is reachable from a normal build setup flow, so a macOS user hits it before reaching the point where
NEMO_SPEECH_GGML_PATCHED=OFFwould make the series irrelevant.Context
Found while packaging NeMo-Speech.cpp as a backend for LocalAI (pin
2e12e2def8a98ed06666f7ee3ca94e7193e04be4). We worked around it downstream by skipping the script on Darwin and configuring with-DNEMO_SPEECH_GGML_PATCHED=OFF, which matches what themetal-*CMake presets already do by inheritingcpu-*. The script still seems worth fixing for anyone who runs it directly.Happy to send a PR if that is useful.