Skip to content

fix: mo purge crashes with unbound variable when no artifacts found#547

Merged
tw93 merged 1 commit intotw93:mainfrom
onurtashan:fix/purge-empty-menu-options-unbound-variable
Mar 7, 2026
Merged

fix: mo purge crashes with unbound variable when no artifacts found#547
tw93 merged 1 commit intotw93:mainfrom
onurtashan:fix/purge-empty-menu-options-unbound-variable

Conversation

@onurtashan
Copy link
Contributor

mo purge crashes immediately when there are no artifacts to clean:

mo purge
Purge Project Artifacts
/opt/homebrew/Cellar/mole/1.29.0/libexec/bin/../lib/clean/project.sh: line 1325: menu_options[@]: unbound variable

The script uses set -euo pipefail at the top. When the scan finds nothing, menu_options stays empty. Bash throws an "unbound variable" error when you try to expand an empty array with set -u active — which is exactly what happens at line 1325 when passing ${menu_options[@]} to select_purge_categories.

The fix is a simple early return after the spinner stops: if menu_options is empty, show a friendly message and exit cleanly instead of crashing.

Fixes #546

…e error

When no artifacts are found during scanning, `menu_options` remains an
empty array. With `set -euo pipefail` active, expanding `${menu_options[@]}`
on an empty array causes a fatal "unbound variable" error (line 1325).

Add an early-return guard after the spinner stops: if no items were found,
print a friendly "No artifacts found to purge" message and exit cleanly.

Fixes tw93#546

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tw93 tw93 merged commit dfedc02 into tw93:main Mar 7, 2026
5 of 6 checks passed
@tw93
Copy link
Owner

tw93 commented Mar 7, 2026

@onurtashan LGTM

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.

[BUG] mo purge gots an error on MacOS 26.3.1

2 participants