Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Official Claude Code Native Installation on Termux (Android aarch64)

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.

Automated Install

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 --repair

Run ./install.sh --help for full usage.


Manual Installation

Prerequisites

  1. Termux: F-Droid or GitHub version.
  2. Architecture: aarch64 (verify with uname -m).
  3. Storage Access: Run termux-setup-storage.

Step 1: Install System Dependencies

pkg update && pkg upgrade -y
pkg install nodejs git binutils file tur-repo glibc-repo -y
pkg update
pkg install glibc -y

Step 2: Install Claude Code Packages

We 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 --force

Step 3: Create the Native Wrapper

Instead 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/claude

Step 4: Fix glibc Environment (If needed)

If 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.so

Step 5: Verification

claude --version

Expected 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.

Troubleshooting & Repair

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.

Full Repair Procedure

If the environment becomes unstable (e.g., after long uptime or failed updates), follow these steps to reset:

  1. Uninstall glibc and repo:

    pkg uninstall -y glibc glibc-repo
    pkg clean
  2. Reinstall from scratch:

    pkg update
    pkg install -y glibc-repo
    pkg install -y glibc
  3. Verify and Restore Wrapper: Ensure the wrapper script at /usr/bin/claude is correct (see Step 3) and verify with claude --version.

Why this works

  • 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 npm platform 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages