Skip to content

ralph-loop: setup script crashes on macOS due to bash 3.2 empty array bug #492

@rockydev

Description

@rockydev

Bug

/ralph-loop fails immediately with:

setup-ralph-loop.sh: line 113: PROMPT_PARTS[*]: unbound variable

Root Cause

The script uses #!/bin/bash which on macOS resolves to /bin/bash (bash 3.2.57). Bash 3.2 has a known bug where expanding an empty array (${array[*]}) with set -u active triggers an "unbound variable" error, even when the array was properly initialized.

Line 6 sets set -euo pipefail, and line 113 does PROMPT="${PROMPT_PARTS[*]}". When no positional arguments have been collected into PROMPT_PARTS, the expansion fails before reaching the empty-prompt validation on line 116.

Fix

Either (or both):

  1. Use #!/usr/bin/env bash instead of #!/bin/bash so users with a modern bash (e.g. via Homebrew) get it picked up automatically.

  2. Use a safe expansion on line 113:

    PROMPT="${PROMPT_PARTS[*]:-}"

    This provides an empty default, avoiding the unbound variable error on bash 3.2.

Environment

  • macOS (Darwin 25.3.0, Apple Silicon)
  • /bin/bash = GNU bash 3.2.57
  • /opt/homebrew/bin/bash = GNU bash 5.3.9 (not used due to #!/bin/bash)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions