[BUG] Bundled ripgrep fails on Raspberry Pi 5 due to jemalloc page size mismatch
Bug Report: Bundled ripgrep fails on Raspberry Pi 5 due to jemalloc page size mismatch
Summary
Custom slash commands in Claude Code fail to load on Raspberry Pi 5 (and potentially other 16KB page size ARM systems) because the bundled ripgrep binary was compiled with jemalloc configured for 4KB pages.
Environment
- Device: Raspberry Pi 5 Model B Rev 1.1
- OS: Debian GNU/Linux 12 (bookworm)
- Kernel: 6.12.47+rpt-rpi-2712
- Architecture: aarch64
- Page Size: 16384 bytes (16KB)
- Claude Code Version: 2.0.14
Steps to Reproduce
- Install Claude Code on Raspberry Pi 5
- Create custom slash commands in
.claude/commands/with proper frontmatter - Start Claude Code session
- Try to use custom slash commands (e.g.,
/my-command) - Commands are not recognized
Root Cause
The bundled ripgrep binary at ~/.claude/local/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-linux/rg fails with jemalloc error:
<jemalloc>: Unsupported system page size
memory allocation of 160 bytes failed
This occurs because:
- The binary was compiled with jemalloc configured for 4KB pages (common in cloud/server ARM systems)
- Raspberry Pi 5 uses 16KB pages (via
getconf PAGESIZE= 16384) - jemalloc's internal structures are sized at compile-time based on page size
- When there's a mismatch, memory allocation fails immediately
Impact
- Custom slash commands don't load - The command scanning process silently fails
- No error shown to user - The failure happens during startup and is only visible in debug logs
- Affects all 16KB page ARM systems - Not just Raspberry Pi 5
Debug Log Evidence
From ~/.claude/debug/*.txt:
[ERROR] Error: Command failed: /home/pi/.claude/local/.../rg --files --hidden --follow --glob *.md /path/.claude/commands
[DEBUG] Total plugin commands loaded: 0
[DEBUG] Slash commands included in SlashCommand tool:
Workaround
Replace the bundled ripgrep with a symlink to system ripgrep (compiled for correct page size):
# Backup broken binary
mv ~/.claude/local/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-linux/rg \
~/.claude/local/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-linux/rg.broken
# Link to system ripgrep
ln -s /usr/bin/rg \
~/.claude/local/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-linux/rg
Or use the automated fix script:
#!/bin/bash
# fix_claude_ripgrep.sh
set -e
RIPGREP_PATH="$HOME/.claude/local/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-linux"
RIPGREP_BINARY="$RIPGREP_PATH/rg"
SYSTEM_RIPGREP="/usr/bin/rg"
# Check page size
PAGE_SIZE=$(getconf PAGESIZE)
if [ "$PAGE_SIZE" != "16384" ]; then
echo "Page size is ${PAGE_SIZE} bytes, not 16KB. No fix needed."
exit 0
fi
# Check if already fixed
if [ -L "$RIPGREP_BINARY" ]; then
echo "Already fixed: $(readlink -f "$RIPGREP_BINARY")"
exit 0
fi
# Apply fix
[ -f "$RIPGREP_BINARY" ] && mv "$RIPGREP_BINARY" "$RIPGREP_BINARY.broken"
ln -s "$SYSTEM_RIPGREP" "$RIPGREP_BINARY"
echo "Fix applied! Restart Claude Code for custom slash commands to load."
Suggested Solutions
Option 1: Compile for 16KB pages (Quick Fix)
Compile the arm64-linux ripgrep binary with jemalloc configured for 16KB pages, or use the system allocator instead of jemalloc.
Option 2: Bundle both versions (Better)
- Bundle both
arm64-linux-4k/rgandarm64-linux-16k/rg - Detect page size at runtime and use appropriate binary
Option 3: Fallback to system ripgrep (Best)
- Detect if bundled ripgrep fails
- Automatically fallback to system ripgrep if available
- Show warning if neither works
Option 4: Drop bundled ripgrep for ARM (Pragmatic)
- Check for system ripgrep on ARM systems during installation
- Only bundle ripgrep for platforms where it's commonly missing (Windows, older systems)
Why This Matters
- Apple Silicon Macs work fine - The
arm64-darwinbinary is properly compiled for 16KB pages - Growing ARM adoption - More developers using Raspberry Pi, ARM servers, Apple Silicon
- Silent failure - Users don't know why their custom commands don't work
Related Issues
This is distinct from:
- #3569 (aarch64 architecture detection) - That's about installation
- #2151 (MCP servers on Pi) - That's about MCP, not core ripgrep functionality
- Other ripgrep issues - Those are about usage, not compilation incompatibility
Additional Context
- System ripgrep (
/usr/bin/rgversion 13.0.0) works perfectly on the same system - The issue persists across Claude Code updates (binary is re-bundled each time)
- This affects any functionality that relies on ripgrep for file scanning
This issue has 11 comments on GitHub. Read the full discussion on GitHub ↗