WSL Enviroment plugin does not work - Here is my fix
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Ralph Wiggum Plugin - Sandbox Security Fix
Problem Summary
The Ralph Wiggum plugin's /ralph-loop command was being blocked by Claude Code's sandbox security due to:
- Multi-line bash commands - Newlines in command blocks are blocked
- Command substitution
$()- Shell command substitution is blocked in command invocations
Error Messages Encountered
Error: Bash command permission check failed for pattern...
Command contains newlines that could separate multiple commands
Error: Bash command permission check failed for pattern...
Command contains $() command substitution
---
Root Cause
The ralph-loop.md command file contained a complex multi-line bash block:
"${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh" $ARGUMENTS
# Extract and display completion promise if set
if [ -f .claude/ralph-loop.local.md ]; then
PROMISE=$(grep '^completion_promise:' .claude/ralph-loop.local.md | sed 's/...')
if [ -n "$PROMISE" ] && [ "$PROMISE" != "null" ]; then
echo "..."
# ... more echo statements
fi
fi
Problems:
- Multi-line structure with newlines
$()command substitution forPROMISE=$(grep ...)- Complex conditionals in the command invocation
---
Solution: Move Logic to Shell Script
Key Principle: Claude Code's sandbox allows complex operations inside .sh script files but blocks them in direct command invocations.
Files Modified
| File | Location |
|------|----------|
| ralph-loop.md | ~/.claude/plugins/cache/claude-plugins-official/ralph-wiggum/*/commands/ |
| setup-ralph-loop.sh | ~/.claude/plugins/cache/claude-plugins-official/ralph-wiggum/*/scripts/ |
---
Fix Details
Step 1: Simplify Command File (ralph-loop.md)
Before:
---
description: "Start Ralph Wiggum loop in current session"
argument-hint: "PROMPT [--max-iterations N] [--completion-promise TEXT]"
allowed-tools: ["Bash(${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh)"]
hide-from-slash-command-tool: "true"
---
# Ralph Loop Command
Execute the setup script to initialize the Ralph loop:
```!
"${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh" $ARGUMENTS
# Extract and display completion promise if set
if [ -f .claude/ralph-loop.local.md ]; then
PROMISE=$(grep '^completion_promise:' .claude/ralph-loop.local.md | sed 's/completion_promise: *//' | sed 's/^"\(.*\)"$/\1/')
if [ -n "$PROMISE" ] && [ "$PROMISE" != "null" ]; then
echo ""
echo "═══════════════════════════════════════════════════════════"
echo "CRITICAL - Ralph Loop Completion Promise"
# ... more echo statements ...
fi
fi
**After:**
```markdown
---
description: "Start Ralph Wiggum loop in current session"
argument-hint: "PROMPT [--max-iterations N] [--completion-promise TEXT]"
allowed-tools: ["Bash(${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh:*)"]
hide-from-slash-command-tool: "true"
---
# Ralph Loop Command
Execute the setup script to initialize the Ralph loop:
```!
"${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh" $ARGUMENTS
Please work on the task. When you try to exit, the Ralph loop will feed the SAME PROMPT back to you for the next iteration.
CRITICAL RULE: If a completion promise is set, you may ONLY output it when the statement is completely and unequivocally TRUE.
### Step 2: Add Logic to Shell Script (`setup-ralph-loop.sh`)
Add the following function at the **end** of the existing `setup-ralph-loop.sh` script:
```bash
# Display completion promise instructions (moved from command invocation to avoid sandbox blocking)
_display_promise_instructions() {
if [[ "$COMPLETION_PROMISE" != "null" ]] && [[ -n "$COMPLETION_PROMISE" ]]; then
echo ""
echo "═══════════════════════════════════════════════════════════"
echo "CRITICAL - Ralph Loop Completion Promise"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "To complete this loop, output this EXACT text:"
echo " <promise>$COMPLETION_PROMISE</promise>"
echo ""
echo "STRICT REQUIREMENTS (DO NOT VIOLATE):"
echo " - Use <promise> XML tags EXACTLY as shown above"
echo " - The statement MUST be completely and unequivocally TRUE"
echo " - Do NOT output false statements to exit the loop"
echo "═══════════════════════════════════════════════════════════"
fi
}
_display_promise_instructions
---
Quick Apply Script
Run this script to automatically apply the fix:
#!/bin/bash
# fix-ralph-loop.sh - Apply sandbox security fix to Ralph Wiggum plugin
PLUGIN_BASE="$HOME/.claude/plugins/cache/claude-plugins-official/ralph-wiggum"
# Find all plugin versions
for VERSION_DIR in "$PLUGIN_BASE"/*/; do
if [ -d "$VERSION_DIR" ]; then
echo "Fixing: $VERSION_DIR"
# Fix 1: Simplify ralph-loop.md command
COMMAND_FILE="$VERSION_DIR/commands/ralph-loop.md"
if [ -f "$COMMAND_FILE" ]; then
cat > "$COMMAND_FILE" << 'EOF'
---
description: "Start Ralph Wiggum loop in current session"
argument-hint: "PROMPT [--max-iterations N] [--completion-promise TEXT]"
allowed-tools: ["Bash(${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh:*)"]
hide-from-slash-command-tool: "true"
---
# Ralph Loop Command
Execute the setup script to initialize the Ralph loop:
```!
"${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh" $ARGUMENTS
Please work on the task. When you try to exit, the Ralph loop will feed the SAME PROMPT back to you for the next iteration. You'll see your previous work in files and git history, allowing you to iterate and improve.
CRITICAL RULE: If a completion promise is set, you may ONLY output it when the statement is completely and unequivocally TRUE. Do not output false promises to escape the loop, even if you think you're stuck or should exit for other reasons. The loop is designed to continue until genuine completion.
EOF
echo " Updated: $COMMAND_FILE"
fi
# Fix 2: Add promise display to setup script (if not already patched)
SETUP_SCRIPT="$VERSION_DIR/scripts/setup-ralph-loop.sh"
if [ -f "$SETUP_SCRIPT" ]; then
if ! grep -q "_display_promise_instructions" "$SETUP_SCRIPT" 2>/dev/null; then
cat >> "$SETUP_SCRIPT" << 'EOF'
Display completion promise instructions (moved from command invocation to avoid sandbox blocking)
_display_promise_instructions() {
if [[ "$COMPLETION_PROMISE" != "null" ]] && [[ -n "$COMPLETION_PROMISE" ]]; then
echo ""
echo "═══════════════════════════════════════════════════════════"
echo "CRITICAL - Ralph Loop Completion Promise"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "To complete this loop, output this EXACT text:"
echo " <promise>$COMPLETION_PROMISE</promise>"
echo ""
echo "STRICT REQUIREMENTS (DO NOT VIOLATE):"
echo " - Use <promise> XML tags EXACTLY as shown above"
echo " - The statement MUST be completely and unequivocally TRUE"
echo " - Do NOT output false statements to exit the loop"
echo "═══════════════════════════════════════════════════════════"
fi
}
_display_promise_instructions
EOF
echo " Patched: $SETUP_SCRIPT"
else
echo " Already patched: $SETUP_SCRIPT"
fi
fi
fi
done
echo ""
echo "Fix applied! Restart Claude Code for changes to take effect."
Save as `fix-ralph-loop.sh`, make executable (`chmod +x fix-ralph-loop.sh`), and run it.
---
## Project Settings (Optional)
Add to your project's `.claude/settings.json` to pre-approve the script:
```json
{
"enabledPlugins": {
"ralph-wiggum@claude-plugins-official": true
},
"permissions": {
"allow": [
"Bash(/home/YOUR_USERNAME/.claude/plugins/cache/claude-plugins-official/ralph-wiggum/*/scripts/*.sh:*)"
]
}
}
Replace YOUR_USERNAME with your actual username.
---
Sandbox Security Rules Reference
| Pattern | Status | Notes |
|---------|--------|-------|
| cmd1 && cmd2 | ✅ OK | Simple chaining allowed |
| cmd1; cmd2 | ✅ OK | Sequential execution allowed |
| $(command) | ❌ Blocked | In command invocations |
| ` command | ❌ Blocked | Backtick substitution |$((arithmetic))
| | ❌ Blocked | Arithmetic expansion |<< EOF
| Heredocs | ❌ Blocked | Multi-line input |$VAR
| Multi-line commands | ❌ Blocked | Newlines in command block |
| Complex if/then/fi | ⚠️ Risky | May be blocked |
| | ✅ OK | Simple variable expansion |.sh` files | ✅ OK | All operations allowed in scripts |
| Logic in
Key Insight: Move all complex shell logic into the .sh script file itself, not the command invocation.
---
Verification
After applying the fix:
# Test directly (should work immediately)
~/.claude/plugins/cache/claude-plugins-official/ralph-wiggum/*/scripts/setup-ralph-loop.sh \
"Test task" --completion-promise "TEST COMPLETE" --max-iterations 1
# Expected output:
# 🔄 Ralph loop activated in this session!
# ...
# ═══════════════════════════════════════════════════════════
# CRITICAL - Ralph Loop Completion Promise
# ═══════════════════════════════════════════════════════════
# To complete this loop, output this EXACT text:
# <promise>TEST COMPLETE</promise>
# ...
Then restart Claude Code and test /ralph-loop:
/ralph-loop "Your task" --completion-promise "DONE" --max-iterations 10
---
Troubleshooting
Still getting blocked?
- Restart Claude Code - Plugin files are cached in memory
- Check file permissions -
chmod +x setup-ralph-loop.sh - Verify the fix -
cat ~/.claude/plugins/cache/claude-plugins-official/ralph-wiggum/*/commands/ralph-loop.mdshould show single-line command - Check for multiple versions - Apply fix to all directories under
ralph-wiggum/
Plugin gets overwritten on update?
The plugin cache may be refreshed. Options:
- Re-apply the fix after updates
- Report the issue to the plugin maintainer
- Create a local fork of the plugin
---
Credits
Fix developed for: UDR
Date: December 2024
Claude Code version: Opus 4.5
Proposed Solution
check above
Alternative Solutions
no other solutions
Priority
Critical - Blocking my work
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗