-
The official npm package (
@openai/codex) ships prebuilt binaries (codex-aarch64-unknown-linux-musl). -
Android’s Bionic libc rejects them with:
error: "…/codex-aarch64-unknown-linux-musl" has unexpected e_type: 2
-
Result: the CLI doesn’t launch in Termux.
Codex has a Rust rewrite. You can compile it directly in Termux and run it natively.
pkg install rust git clang make
git clone https://github.com/openai/codex.git
cd codex/codex-rs/cli
cargo build
Binary appears at:
~/codex/codex-rs/target/debug/codex
rm $PREFIX/bin/codex
ln -s ~/codex/codex-rs/target/debug/codex $PREFIX/bin/codex
codex --help
codex
You’ll see the Codex splash screen and login prompt. ✅
The optimized --release build needs more memory than most phones have.
You must enable swap before compiling.
fallocate -l 4G ~/swapfile
chmod 600 ~/swapfile
mkswap ~/swapfile
(If fallocate is missing: dd if=/dev/zero of=~/swapfile bs=1M count=4096)
swapon ~/swapfile
Check with:
free -h
cd ~/codex/codex-rs/cli
cargo build --release -j1
Binary appears at:
~/codex/codex-rs/target/release/codex
swapoff ~/swapfile
- The npm package doesn’t work on Android.
- Compiling from source in Termux gives you a working native Codex CLI.
- Debug build is fine for testing; release build needs swap to finish.
- Once linked, the CLI behaves just like on Linux/macOS — login, API key, sandboxed execution — all from your phone. 😎