This guide provides a reproducible method for installing the official Claude Code (Anthropic CLI) on Termux. It uses the glibc repository to run the native Linux binary, bypassing the "Unsupported platform" error.
An install.sh script is included that automates all steps below.
# Fresh install
./install.sh
# Preview what it will do without executing anything
./install.sh --dry-run
# Reset a broken glibc environment and restore the wrapper
./install.sh --repairRun ./install.sh --help for full usage.
- Termux: F-Droid or GitHub version.
- Architecture:
aarch64(verify withuname -m). - Storage Access: Run
termux-setup-storage.
pkg update && pkg upgrade -y
pkg install nodejs git binutils file tur-repo glibc-repo -y
pkg update
pkg install glibc -yWe install the main CLI package and force-install the native linux-arm64 binary.
# Main wrapper package
npm install -g @anthropic-ai/claude-code
# Official native aarch64 binary (force-installed for Android)
npm install -g @anthropic-ai/claude-code-linux-arm64 --forceInstead of moving binaries, we create a direct wrapper script that uses the glibc runner (grun) to execute the native binary. Use /bin/sh with absolute paths to avoid shell initialization issues. We also clear LD_PRELOAD to prevent conflicts with Termux's internal libraries.
# Create the wrapper with absolute paths and clear LD_PRELOAD
cat <<'EOF' > /data/data/com.termux/files/usr/bin/claude
#!/bin/sh
# Clear LD_PRELOAD to avoid conflicts between Termux and glibc libraries
export LD_PRELOAD=
exec /data/data/com.termux/files/usr/glibc/bin/grun /data/data/com.termux/files/usr/lib/node_modules/@anthropic-ai/claude-code-linux-arm64/claude "$@"
EOF
# Make executable
chmod +x /data/data/com.termux/files/usr/bin/claudeIf you encounter invalid ELF header errors, replace the ASCII linker scripts with symbolic links:
# Fix linker script issues
ln -sf /data/data/com.termux/files/usr/glibc/lib/libc.so.6 /data/data/com.termux/files/usr/glibc/lib/libc.so
ln -sf /data/data/com.termux/files/usr/glibc/lib/libm.so.6 /data/data/com.termux/files/usr/glibc/lib/libm.soclaude --versionExpected output: 2.x.x (Claude Code)
Note: Do not use bash in the shebang or variable expansion—new shell sessions may have glibc initialization issues. The absolute path approach is more robust.
If you encounter errors like invalid ELF header for libc.so or version 'LIBC' not found, it usually indicates a corruption or conflict in the glibc environment.
If the environment becomes unstable (e.g., after long uptime or failed updates), follow these steps to reset:
-
Uninstall glibc and repo:
pkg uninstall -y glibc glibc-repo pkg clean
-
Reinstall from scratch:
pkg update pkg install -y glibc-repo pkg install -y glibc
-
Verify and Restore Wrapper: Ensure the wrapper script at
/usr/bin/claudeis correct (see Step 3) and verify withclaude --version.
- glibc-repo: Provides a standard Linux C library environment within Termux.
- grun: A loader that runs glibc-linked binaries using the libraries in
/usr/glibc. - --force: Bypasses the
npmplatform check that usually blocks "linux" packages on "android". - LD_PRELOAD=: Clearing this environment variable prevents Termux's internal libraries from interfering with the glibc-linked native binary.
Verified and updated on May 6, 2026.
Wrapper revised to use /bin/sh with absolute paths and LD_PRELOAD clearing for robustness.