Skip to content

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

Merged
maxamillion merged 1 commit into
NVIDIA:mainfrom
benoitf:macos-shell-script
May 15, 2026
Merged

fix(scripts): replace mapfile with bash 3.2-compatible read loop#1334
maxamillion merged 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)

@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.

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.
@benoitf benoitf force-pushed the macos-shell-script branch from 70b7923 to 27d4d45 Compare May 15, 2026 12:58
@benoitf
Copy link
Copy Markdown
Contributor Author

benoitf commented May 15, 2026

PR rebased

Copy link
Copy Markdown
Collaborator

@maxamillion maxamillion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@maxamillion maxamillion merged commit a1fb9bd into NVIDIA:main May 15, 2026
4 checks passed
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.

2 participants