[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
11 Comments
Better Solution: Compile with Higher lg-page Value
A superior fix has been identified: compile the ripgrep binary with jemalloc configured for a higher maximum page size using
--with-lg-page.The Fix
When building ripgrep for
arm64-linux, use:Or for Rust's jemalloc-sys crate:
Why This Works
The
lg-pageparameter sets the logarithm base-2 of the MAXIMUM page size:lg-page=12→ 2^12 = 4KB (current bundled binary)lg-page=14→ 2^14 = 16KBlg-page=16→ 2^16 = 64KB (recommended)Key benefit: A binary compiled with a higher lg-page value works with all smaller page sizes:
| Compiled with | 4KB systems | 16KB systems | 64KB systems |
|--------------|-------------|--------------|--------------|
| lg-page=12 | ✅ | ❌ | ❌ |
| lg-page=14 | ✅ | ✅ | ❌ |
| lg-page=16 | ✅ | ✅ | ✅ |
Advantages Over Other Solutions
Compared to symlink workaround:
Compared to bundling multiple binaries:
Compared to system ripgrep fallback:
Trade-offs
Recommendation
Compile the
arm64-linuxripgrep binary withJEMALLOC_SYS_WITH_LG_PAGE=16to support:This is a one-line build configuration change that fixes the issue for all ARM Linux systems.
I just wanted to add at least one "me too" post so we know its not just @hydrohelix 's issue. I have to implement the workaround every morning before I get started or none of my agents show up in the app.
Thanks for the thorough report, I came here to make one and yours is better than I intended.
👍 I'm having the same issue
I'm having the same issue using Asahi linux. Even with the updated jemalloc, I needed to add to
~/.claude/settings.jsonThis issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Still an issue
We're also seeing this on an HPC cluster that uses 64KB pages
I'm trying out the
USE_BUILTIN_RIPGREP=0approach for nowsame issues, and I think one possible solution is providing an option to use our system rg instead of the built-in rg?
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.