GeezerVison is showing github.com — [FEATURE]: Add android to v2 npm package supported OS for Termux compatibility · Issue #47612 · anomalyco/opencode
[FEATURE]: Add android to v2 npm package supported OS for Termux compatibility #47612DescriptionDescription
OpenCode v2 beta (@opencode-ai/cli@beta) works on Termux/Android aarch64 using the existing musl loader, but npm rejects the install because android is not in the package supported OS list.
Note This issue does not exist in v1 — v1 requires a proxy/libresolvefix workaround because of Bun io_uring. v2 replaces Bun with Node.js, eliminating that problem entirely.
Test results
- Device: Pixel 10 (Android 17, Termux 0.119, aarch64)
- Package:
@opencode-ai/[email protected]
| Command |
Result |
opencode2 --version |
opencode2 v0.0.0-beta-19192 ✅ |
opencode2 --help |
Works ✅ |
Binary dependencies (click to expand)
The v2 musl binary only depends on:
libstdc++.so.6
libc.musl-aarch64.so.1
No Bun, no JSC, no WebKit — significantly simpler than v1.
Current behavior
npm error code EBADPLATFORM
npm error notsup Unsupported platform for @opencode-ai/cli: wanted {"os":"darwin,linux,win32"} (current: {"os":"android"})
Tip Workaround:
npm install -g @opencode-ai/cli@beta --force
curl -fsSL https://raw.githubusercontent.com/DEAD1nsane/opencode-termux-musl/master/scripts/fix-opencode2-wrapper.sh | sh
The --force flag bypasses the OS check. The fix script is required because the npm postinstall generates a broken wrapper that execs itself instead of opencode2.exe, causing infinite recursion.
Full install output (click to expand)
$ npm install -g @opencode-ai/cli@beta
npm error code EBADPLATFORM
npm error notsup Unsupported platform for @opencode-ai/[email protected]: wanted {"os":"darwin,linux,win32","cpu":"arm64,x64"} (current: {"os":"android","cpu":"arm64"})
npm error notsup Valid os: darwin,linux,win32
npm error notsup Actual os: android
Request
Add android to the supported OS list in the v2 npm package, plus android prebuilds for the two native dependencies that still lack them (details below).
Warning Without this change, Termux users must use --force to install, which bypasses all platform safety checks. The generated wrapper also has a recursive self-call bug that requires a separate fix script. Both are not discoverable and give a poor first impression.
Why this should be straightforward (click to expand)
- The v2 binary is already compiled as
linux-arm64-musl — it runs on Android without modification
- The
postinstall.mjs already handles platform detection via os.platform() which returns "android" on Termux
- Adding
"android" to the os field in package.json is a one-line change
- No code changes needed for the CLI binary itself — it works as-is
Note The os field fix is necessary but not sufficient: without android prebuilds for the native dependencies, install succeeds and TUI/pty break at runtime. Blocker list first raised by @Hope2333 in this comment; registry status re-checked 2026-09-24:
@parcel/[email protected] — already ships @parcel/watcher-android-arm64. Resolved.
@opentui/[email protected] — 8 platform targets, zero android. Needs an NDK CI build.
@opencode-ai/[email protected] — darwin + linux gnu/musl only, no android (linux-arm64-musl won't dlopen on Bionic). Needs an android target.
Actual remaining work: the os field + those two prebuilds.
Wrapper bug details (click to expand)
The npm postinstall generates a shell wrapper at $PREFIX/bin/opencode2 that contains:
exec "$PREFIX/lib/node_modules/@opencode-ai/cli/bin/opencode2" "$@"
This execs the wrapper script itself (infinite recursion), not the actual binary (opencode2.exe). Additionally, the wrapper:
- Unnecessarily starts the Python HTTP proxy (v2 is Node.js-based, doesn't need it)
- Sets
HTTP_PROXY/HTTPS_PROXY which v2 doesn't need
The fix script (fix-opencode2-wrapper.sh) patches the ELF interpreter (binary expects /lib/ld-musl-aarch64.so.1 but Termux installs at $PREFIX/lib/) and creates a correct wrapper.
If this issue is resolved (adding android to supported OS), the postinstall.mjs should also be updated to generate a correct wrapper on Android.
Related
Reacted by Hao Lyu, Baidaofu, Kim dongwook and Jonathan Chemla ActivityHope2333 commented on Sep 22, 2026 Community workaround: Native bionic build for Termux
While official android support in the npm package would be ideal, heres a community solution thats been working well:
What we built
Source-compiled bionic packages for opencode v2.0.x on Termux (aarch64):
# Install (deb)
dpkg -i opencode_2.0.12_aarch64.deb
# Or (pacman)
pacman -U opencode-2.0.12-1-aarch64.pkg.tar.xz
How it works
- Built from source using Android Bun 1.4.2 toolchain
- Pure bionic ELF — no glibc, no proot, no wrapper scripts
- TUI works natively (after rebuilding opentui bionic .so from source)
- 13 versions available (2.0.0–2.0.12)
Repo
https://github.com/Hope2333/opencode-termux (branch: native-android)
For upstream consideration
The main blocker for official android support is:
@opentui/core needs a bionic build (currently only glibc/musl)
@opencode-ai/pty prebuilt binaries dont include android
@parcel/watcher needs android support
If these three packages added android targets, the official npm package would work on Termux natively. DEAD1nsane commented on Sep 24, 2026
Source-compiled bionic packages for opencode v2.0.x on Termux (aarch64)
- Built from source using Android Bun 1.4.2 toolchain
- Pure bionic ELF — no glibc, no proot, no wrapper scripts
- TUI works natively (after rebuilding opentui bionic .so from source)
One correction, because accuracy matters on a thread where users decide what to trust: per your own docs/transplant.md, this isn't a source build. The method takes the official android Bun binary and grafts the npm opencode-linux-arm64 module graph into it — patching BUN_COMPILED.size, injecting R_AARCH64_RELATIVE relocations, swapping in an NDK-built libopentui.so. That's binary transplant, and it's genuinely impressive reverse-engineering. But "built from source" sets the wrong expectation about robustness, so the wording is worth fixing.
The robustness question is real, and your docs are upfront about it: opencode 1.18's .bun section layout change broke the pipeline until you re-engineered the graft, which means every upstream release needs re-verification against your lock list. That's ongoing per-release maintenance against an upstream that doesn't guarantee a stable grafting surface — users should go in with eyes open.
Same for the limitations, which your docs honestly list but the comment glosses over: the v2.0.0 TUI segfault in Bun's DNS path, the serve config bug, ~2s cold starts (12s on UPX). And release assets sit at 0–7 downloads, so field testing so far is essentially just you.
For comparison, the musl-loader approach runs byte-identical official binaries — no surgery, nothing version-specific to maintain. The trade is runtime overhead instead of maintenance overhead. Different bets for different priorities.
Credit where due: your three upstream blockers (@opentui/core, @opencode-ai/pty, @parcel/watcher) are correct and are the only durable fix on this thread — that part of the comment is genuinely useful.
Follow-up on that blocker list — checked the registries today, and one of the three is already resolved:
@parcel/[email protected] already ships @parcel/watcher-android-arm64. Unless v2 pins an older watcher, that blocker is gone.
@opentui/[email protected] ships 8 platform targets, zero android. Blocker stands — needs an NDK CI build (Zig's bionic support is incomplete, but third-party forks prove it's buildable).
@opencode-ai/[email protected] ships darwin + linux gnu/musl only — no android, and linux-arm64-musl won't dlopen on Bionic. Blocker stands.
So the "android" OS-field fix I'm asking for here is necessary but not sufficient: without the opentui + pty android prebuilds, install succeeds and TUI/pty break at runtime. The actual work list is those three items, one of which is already done.
P.S. I've folded the above blocker status into the main issue body so the request reflects the full scope (OS field + the two prebuilds), with credit to @Hope2333 for the original list. DEAD1nsane commented on Oct 6, 2026 Status update: the fix for this issue is PR #48405 (fix: add Android/Termux support to postinstall.mjs) — adds android: \"linux\" to the platform map and makes isMusl() return true on Android so npm install -g selects the musl binary instead of failing with android-arm64 unsupported. It targets current Termux (F-Droid/apt, musl via patchelf); native Bionic binaries are a separate follow-up noted in the PR thread.
The PR branch was just refreshed onto current dev (mergeable, checks green) and is awaiting maintainer review.
⚠️ One note for anyone landing here from search: this repo runs an automated nightly cleanup that closes PRs older than 1 month with fewer than 2 positive reactions. #48405 was opened Sep 11 and becomes eligible for auto-close on Oct 12. A 👍 or 🚀 on the PR before then genuinely helps it survive long enough to be reviewed — if this issue affects your Termux setup, that's the highest-leverage way to help it land. opencodejr commented on Oct 28, 2026 Thanks for the detailed write-up and for testing the musl binary on Termux.
You're asking for the v2 npm package to officially support Android/Termux (aarch64). That means accepting android as an OS, picking the musl binary and generating a working launcher on Android, and shipping android prebuilds for @opentui/core and @opencode-ai/pty so the TUI and pty work at runtime. Right now v2 only targets darwin, linux and win32, so it's a request for a new platform rather than a bug. Maintainers will consider it.
Related issues and PRs:
- fix: add Android/Termux support to postinstall.mjs #48405: your PR mapping android to the linux-musl binary in
postinstall.mjs (closed without merging)
- OpenCode AI V2 Support Termux #50203: community Termux wrapper for v2 (closed)
- core: PTY creation 500s on linux-arm64-musl (bundled glibc librust_pty cannot dlopen) #56456: PTY failing to load on linux-arm64-musl (closed)
- watcher: directory-type subscriptions always fail on android ("backend not supported"), file/entries fall back fine #58503, tui: pasting large text freezes Termux/Android; freeze time scales with paste size #59909, TUI leaves stale "ghost" characters on screen in Termux, only cleared by forced full redraw #47255, tui: transcript images and image viewer render garbled, underscaled blocks (Termux, no graphics protocol) #52492: Termux/Android runtime issues (watcher, paste freeze, ghost characters, image rendering)
DEAD1nsane commented on Oct 29, 2026
Thanks for the detailed write-up and for testing the musl binary on Termux.
You're asking for the v2 npm package to officially support Android/Termux (aarch64). That means accepting android as an OS, picking the musl binary and generating a working launcher on Android, and shipping android prebuilds for @opentui/core and @opencode-ai/pty so the TUI and pty work at runtime. Right now v2 only targets darwin, linux and win32, so it's a request for a new platform rather than a bug. Maintainers will consider it.
Related issues and PRs:
- fix: add Android/Termux support to postinstall.mjs #48405: your PR mapping android to the linux-musl binary in
postinstall.mjs (closed without merging)
- OpenCode AI V2 Support Termux #50203: community Termux wrapper for v2 (closed)
- core: PTY creation 500s on linux-arm64-musl (bundled glibc librust_pty cannot dlopen) #56456: PTY failing to load on linux-arm64-musl (closed)
- watcher: directory-type subscriptions always fail on android ("backend not supported"), file/entries fall back fine #58503, tui: pasting large text freezes Termux/Android; freeze time scales with paste size #59909, TUI leaves stale "ghost" characters on screen in Termux, only cleared by forced full redraw #47255, tui: transcript images and image viewer render garbled, underscaled blocks (Termux, no graphics protocol) #52492: Termux/Android runtime issues (watcher, paste freeze, ghost characters, image rendering)
this isn't listed as a bug, I posted this as [FEATURE] so it would be considered as a request, because yes that is what I'm asking for. and would very much appreciate it. Eslamasabry commented on Oct 31, 2026 If the goal is to have OpenCode on the phone without patching Termux packages: I'm the author of OpenCode Mobile (unofficial, MIT), which installs its own Ubuntu with proot and runs OpenCode 2 there, no Termux needed. It doesn't solve the npm OS-list issue for people who want Termux specifically. Repo: https://github.com/Eslamasabry/opencode-mobile-next.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|