PageAI-Pro / PageAI-Pro/ralph-loop
Run dies after the first iteration because of ((line_count++)) under set -e
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 304
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
Took me a while to track this one down. ralph.sh runs with set -e, and display_final_summary in scripts/lib/output.sh bumps its counter with ((line_count++)). That form returns the value before the increment, so when line_count is 0 the arithmetic command exits 1 and set -e kills the whole script.
$ bash -c 'set -e; n=0; echo before; ((n++)); echo after'
before
$ echo $?
1
Net effect is the run dies partway through printing the first summary and never reaches iteration 2, no matter what you pass to -n. What you see:
─────────────────────────────────────────────────────────────────
Iteration Summary
─────────────────────────────────────────────────────────────────
Bash command=find .agent/screenshots -type f 2>&1
📦 Stopping sandbox ralph-claude-...
Note the missing closing separator and no └── ✓ Iteration 1 complete. It exits 1, which is the same as EXIT_MAX_ITERATIONS, so at a glance it just looks like the run ended normally. That's what threw me for a while.
Both hits are in display_final_summary, lines 164 and 168. Swapping them for line_count=$((line_count + 1)) fixes it since assignment always returns 0.
preview.sh:70 also has an i++ but it's the for ((...)) form, where the status isn't propagated, so that one's fine.
Nothing Windows-specific here, should hit any bash.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in scripts/lib/output.sh at display_final_summary, specifically the two counter updates at lines 164 and 168. Reproduce the failure with ralph.sh under set -e, then verify the summary prints its closing separator and the Iteration 1 completion marker before the next iteration runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100