Skip to content

fix(scripts): replace mapfile with bash 3.2-compatible read loop#1334

Open
benoitf wants to merge 1 commit into
NVIDIA:mainfrom
benoitf:macos-shell-script
Open

fix(scripts): replace mapfile with bash 3.2-compatible read loop#1334
benoitf wants to merge 1 commit into
NVIDIA:mainfrom
benoitf:macos-shell-script

Conversation

@benoitf
Copy link
Copy Markdown
Contributor

@benoitf benoitf commented May 12, 2026

Summary

Replace mapfile -t with a while read loop in docker-build-image.sh and stage-prebuilt-binaries.sh to ensure compatibility with bash 3.2, the default shell on macOS.

mapfile (also known as readarray) was introduced in bash 4.0. macOS ships with bash 3.2 due to the GPLv3 licensing change in bash 4+, so any script using mapfile fails on a stock macOS developer machine:

line XX: mapfile: command not found

Related Issue

Changes

All three call sites follow the same mechanical replacement:

# Before (requires bash 4.0+)
mapfile -t arches < <(prebuilt_arches)

# After (works on bash 3.2+)
local arches=()
while IFS= read -r _a; do arches+=("$_a"); done < <(prebuilt_arches)
File Location Function
tasks/scripts/docker-build-image.sh missing_prebuilt_paths() Detects which prebuilt binaries are absent
tasks/scripts/docker-build-image.sh ensure_prebuilt_binaries() Stages prebuilt binaries before Docker build
tasks/scripts/stage-prebuilt-binaries.sh top-level Detects host architectures for cross-compilation

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Manual Testing

  • Run tasks/scripts/stage-prebuilt-binaries.sh on macOS (bash 3.2) and confirm it no longer errors on mapfile.
  • Run mise run docker:build and verify prebuilt binary staging still works on both macOS and Linux.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

macOS ships bash 3.2 which lacks mapfile (introduced in bash 4.0),
causing docker-build-image.sh and stage-prebuilt-binaries.sh to fail
on stock macOS developer machines.
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 12, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant