Run opencode natively on Termux/Android — no proot-distro, no Ubuntu
chroot, no emulation layer. Patches the community aarch64 musl build so it
links against Termux's own musl loader, then wires opencode into the
environment so it knows it's on a patched Bionic/aarch64 setup and can
self-diagnose failures (segfaults, invalid ELF, grep/ripgrep dying) instead of
guessing.
Unofficial, community project — not affiliated with or endorsed by the opencode authors. Ships no binary:
install.shdownloads the aarch64 musl build from C04-wq/opencode-termux releases (version + SHA-256 taken from its npmrelease-checksums.json) and patches it locally.
- opencode publishes no
android-arm64/Bionic build. The communityopencode-termuxbuild is musl-linked, and its ELF interpreter must be patched to the musl loader shipped beside it. - The stock npm launcher exported
LD_PRELOAD/LD_LIBRARY_PATH, which broke the Bionicbash/ripgrepthat opencode itself spawns. This repo replaces it with a wrapper that scopes the library path to a singleexec(--library-path), so nothing leaks into children. - opencode's autoupdater would silently swap in an unpatched build. This repo
disables it (
OPENCODE_DISABLE_AUTOUPDATE=1+ config) and provides a verifiedtermux-update-opencodepath instead, with rollback.
pkg install -y git
git clone https://github.com/jronminh/opencode-code-termux-native.git
cd opencode-code-termux-native
bash install.shThen run opencode.
- Installs deps (
curl jq patchelf ripgrep tar coreutils file ca-certificates ...). - Downloads and SHA-256-verifies the aarch64 musl build, patches the ELF
interpreter to
~/.opencode/ld-musl-aarch64.so.1, and stages it under~/.opencode/opencode-native/. - Installs the
opencodewrapper into$PREFIX/bin(loader--library-path,OPENCODE_DISABLE_AUTOUPDATE=1,TMPDIR). - Wires
autocheck.shinto~/.bashrc— self-heal + update check on each new shell (opencode has no hook system). - Sets
"autoupdate": falsein~/.config/opencode/opencode.jsonc(previous version backed up). - Merges
environment.md.templateinto~/.config/opencode/environment.md(wired in viainstructions) and installs theopencode-termux-doctorskill.
opencode— the patched binary, via the wrapper.termux-update-opencode— download → verify → patch → install, with rollback.termux-opencode-features status|enable|disable— opt-in features.termux-opencode-job— headlessopencode runon Android's JobScheduler (not plain cron, which Android kills when the screen locks).
- adb-bridge — see and drive the entire Android screen (screenshots,
exact-coordinate
uiautomatordumps, tap/swipe, full-system logcat) through termux-adb-bridge's shell-UID daemon (dsh) — no Shizuku, noadb. Security-sensitive (commands run at theshellUID).termux-opencode-features enable adb-bridge(requires termux-adb-bridge installed and its daemon running). - notifications — n/a: opencode has no settings.json hook system.
~/.opencode/opencode # patched binary
~/.opencode/ld-musl-aarch64.so.1 # + libc/libstdc++/libgcc beside it
~/.opencode/opencode-native/ # doctor.sh, autocheck.sh, update.sh, jobs
~/.config/opencode/opencode.jsonc # global config (autoupdate off)
~/.config/opencode/environment.md # managed notes (begin/end markers)
~/.config/opencode/skills/ # opencode-termux-doctor, adb-bridge
$PREFIX/bin/opencode # wrapper
$PREFIX/bin/termux-{update-,}opencode-*
bash ~/.opencode/opencode-native/doctor.sh — checks the interpreter, leaked
LD_*, autoupdater state, Termux freshness, disk space, and the adb-bridge
daemon.
If opencode segfaults on launch, reports invalid ELF header, has grep/ripgrep
dying mid-tool-call, or an update breaks it: invoke the opencode-termux-doctor
skill (or run doctor.sh) before hand-editing anything under
~/.opencode/opencode-native/ or $PREFIX/bin/opencode.
- Android/Termux aarch64, Termux from F-Droid or GitHub (not Play Store).
- ~200 MB for the patched binary plus the musl runtime libs.
Built with AI assistance from Claude (Anthropic) and DeepSeek
(deepseek-v4-flash, via opencode). All design decisions, review, and testing
are the maintainer's.
GPL-3.0 — see LICENSE.