Skip to content

ralph-loop: setup script crashes with unbound variable when no prompt provided #652

@Pran-Ker

Description

@Pran-Ker

Bug

Running /ralph-loop:ralph-loop without a prompt argument crashes with:

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

Root Cause

The script uses set -euo pipefail (line 6), which includes -u (treat unbound variables as errors). When no positional arguments are passed, PROMPT_PARTS remains an empty array initialized on line 9:

PROMPT_PARTS=()

On line 113, the expansion ${PROMPT_PARTS[*]} triggers the unbound variable error because bash's set -u treats empty arrays as unbound:

PROMPT="${PROMPT_PARTS[*]}"

This crashes before the helpful usage message on lines 116–127 can be displayed.

Expected Behavior

Running /ralph-loop:ralph-loop without arguments should display the usage instructions:

❌ Error: No prompt provided

   Ralph needs a task description to work on.

   Examples:
     /ralph-loop Build a REST API for todos
     /ralph-loop Fix the auth bug --max-iterations 20
     ...

Suggested Fix

Replace line 113 with a safe expansion that handles empty arrays:

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

The :- default value syntax prevents the unbound variable error while still allowing the empty check on line 116 to work correctly.

Environment

  • macOS (Darwin 25.3.0)
  • bash with set -euo pipefail
  • Plugin version: d5c15b861cd2 (commit d5c15b861cd23e3102215c26020368ad5134dc47)

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