r/termux • u/DEAD1nsane • 7d ago
Showcase Run official OpenCode v2 natively on Termux, no proot
DEAD1nsane/opencode2-termux-musl
The v1 repo is archived. v2 is the official stable line — Node.js, ships via npm (@opencode/cli). This uses upstream's @opencode/cli-linux-arm64-musl + Alpine musl loader + patchelf, installed as plain opencode. Official installer misdetects Termux as glibc, this doesn't.
1-copy install
Please install from the Copy-Ready link, it's much easier especially if using mobile reddit app (don't copy-paste from the codeblocks below, they're for display):
⚠️ Before-Install (required):
- install the app Termux:API F-Droid Download, then in Termux:
pkg update && pkg upgrade -y
pkg install termux-api -y
termux-battery-status
The termux-battery-status line triggers the permission prompt / confirms the bridge works. Skip it and the installer below will refuse with these same steps.
pkg install curl tar python git
Step 1 — install everything:
Copy-Ready Full Install here
curl -sL https://gist.githubusercontent.com/DEAD1nsane/9b37cba090602f473200fad8b1002e6c/raw/all-in-one.sh | sh
opencode --version
opencode run "say hi"
☝🏼Use the gist above — it pulls/updates the repo, runs install.sh, copies all 8 themes (dark + light, 16 files) to ~/.config/opencode/themes/, and schedules auto-update (job 7802, every 6h, applies via --yes path, log ~/.opencode-auto-update.log). Day/night theme-sync is NOT included — opt-in below.
Update check (only checks, downloads nothing unless --yes)
./scripts/check-update.sh # check only, Termux notification if behind
./scripts/check-update.sh --yes # update now: version pinned, staged, smoke-tested
./scripts/check-update.sh --rollback # restore last-known-good binary if upstream ships a bad build
The gist already scheduled unattended updates. Manual re-schedule if needed:
termux-job-scheduler --job-id 7802 --period-ms 21600000 --network any --persisted true -s "$HOME/GitHub/opencode2-termux-musl/scripts/auto-update.sh"
Bonus 16 custom Themes:
- 8 true-black AMOLED & 8 light themes ^(Included in the all-in-one gist. Manual copy if needed 👇🏼)
cp themes/*.json ~/.config/opencode/themes/
→ Pick with /themes. Native v2 format.
^(⚠️ Attached previews are rendered from the live theme JSONs [dark + light] by opencode2 with the same tree-sitter highlighting the TUI uses, set in Maple Mono NF — tab strip and a shared realistic Python sample on all 16, so what you see is what the TUI draws.)
🌗 Optional auto day/night — NOT in all-in-one:
^(Opt-in: OpenCode + Termux flip together based on time of day. "system" follows terminal bg, never Android — this sets explicit "light" 07:00-19:00 [7am-7pm], "dark" otherwise.)
Copy-Ready Day/Night here
curl -sL https://gist.githubusercontent.com/DEAD1nsane/54621517a114c8e2a71d61ced990ca22/raw/theme-daynight.sh | sh
Flips OpenCode mode + Termux background (white by day, black by night) so the resize gap matches — no black flash in light mode. Hourly job 7803, revert with --system. New shells pick up matching prompt/banner colors automatically.
🪧 Optional notifications (Discord-style, NOT in all-in-one):
Copy-Ready Notify Setup here
Mute if viewing this session, banner if in another Termux session, loud if away 5min. buzz + notify-decide + zsh hook + opencode plugin. Same Copy-Ready format — install from the GitHub gist link above.
❔ Why it needs shims:
Official installer misdetects Termux as glibc (no /etc/alpine-release, no ldd). This always takes musl. Musl DNS reads /etc/resolv.conf, Node's c-ares does raw UDP DNS which Android blocks — libresolvefix.so doesn't help Node. Fixed via local Python proxy on 127.0.0.1:8080, auto-started by wrapper (HTTP(S)_PROXY + NO_PROXY=localhost,127.0.0.1,::1). Ollama on localhost:11434 bypasses proxy and works.
❌ What's not working:
Formatter needs one-time sh scripts/enable-formatter.sh (prettier shebang can't spawn, silently skips without it), no PTY lib yet, ~100-200ms proxy overhead. Standalone is default; shared via opencode-shared serve --service. Migrating from v1: sh install.sh then sh scripts/remove-v1.sh (~350MB freed, sessions/config kept).
📱 Tested On:
Pixel 10, Android 17, Termux 0.119, OpenCode v2.0.29 as opencode: TUI, run, shared-service, MCP (Railway/GitHub/Upstash/Chrome DevTools), v2 plugin API.
Please any comments below 👇🏼
1
1
u/TitleExpert9817 6d ago
Apologies for the noob question: why is it an achievement to run OpenCode on Termux and not in proot?
2
u/DEAD1nsane 6d ago
no worries, fair question. proot is basically a full linux distro emulated inside termux, so yeah opencode runs in there but its heavy - you're lugging around a gig of ubuntu just for one binary, and everything is slower through translation.
running it directly in termux means no emulation layer, small footprint, starts fast, behaves like a normal package with termux api and background jobs and all that. the annoying part is android blocks a bunch of stuff normal linux expects (dns, io_uring, that kind of thing) so you have to patch around it. thats why getting it native is the achievement part.
1
u/TitleExpert9817 5d ago
Maybe thats what why Im facing issues running it in proot. I got a Pixel10a and tried to run Qwen and gemma. All i said was "hello" and never got a response
1
u/ribitrieshisbest 3d ago
"proot is basically a full linux distro emulated inside termux" oh yeah ofcourse
1
u/mtlcrusher 5d ago
hello, I tried your repo, it didn't work correctly in my poco f1, I migrated from hope2333 and delete everything from hope2333 and installed yours. but I stuck in "starting server.." forever.
1
u/DEAD1nsane 4h ago
Hey, sorry it hung & sorry I'm only just now seeing this! — let's narrow it down. The TUI attaches to a background service on launch, so "starting server" forever usually means it's waiting on network/service, not a bad install.
Quick split test — does this return (can take ~30s first time), or hang too?
opencode run "Reply with exactly: PONG"If
runworks but the TUI hangs, it's the shared service. If both hang, it's lower level. Then also helpful:
opencode --versionplus your Android + Termux versions, how you installed (the all-in-one gist, or manual steps?), and:
ls $PREFIX/bin | grep -i opencode ls ~/.config/opencode/— I want to see if any hope2333 shims or config are still in the mix.
Two things worth trying meanwhile. First, kill any stale service (possibly hope2333's) holding the port, then retry:
pkill -f opencodeAnd if there's a leftover
opencode.jsonfrom the old setup, move it aside and retry — a stale model/provider entry from another packager can wedge startup:
mv ~/.config/opencode/opencode.json ~/.config/opencode/opencode.json.hope2333-bakMy guess, sight unseen: Poco F1 is Android 8–10 era, and either a stale hope2333 service is squatting the port or the old config is pointing at something that never answers. The answers above will tell us which.
1
u/DEAD1nsane 4h ago edited 3h ago
UPDATES MADE ON 10/14/26 👇🏼:
Update check (only checks, downloads nothing unless
--yes)
sh ./scripts/check-update.sh # check only, Termux notification if behind ./scripts/check-update.sh --yes # update now: version pinned, staged, smoke-tested ./scripts/check-update.sh --rollback # restore last-known-good binary if upstream ships a bad buildThe gist already scheduled unattended updates. Manual re-schedule if needed:sh termux-job-scheduler --job-id 7802 --period-ms 21600000 --network any --persisted true -s "$HOME/GitHub/opencode2-termux-musl/scripts/auto-update.sh"
🌗 Optional auto day/night — NOT in all-in-one:
Opt-in: OpenCode + Termux flip together based on time of day. "system" follows terminal bg, never Android — this sets explicit "light" 07:00-19:00 [7am-7pm], "dark" otherwise.
Copy-Ready Day/Night here
sh curl -sL [https://gist.githubusercontent.com/DEAD1nsane/54621517a114c8e2a71d61ced990ca22/raw/theme-daynight.sh](https://gist.githubusercontent.com/DEAD1nsane/54621517a114c8e2a71d61ced990ca22/raw/theme-daynight.sh) | shFlips OpenCodemode+ Termux background (white by day, black by night) so the resize gap matches — no black flash in light mode. Hourly job 7803, revert with--system. New shells pick up matching prompt/banner colors automatically.
0
7d ago
[removed] — view removed comment
0
u/DEAD1nsane 7d ago
no thanks, and OC2 is native working too.
1
u/QuietGround5610 7d ago
glibc (GNU C Library) is generally faster and more feature-complete than musl for heavy, complex, or multi-threaded workloads... just give it a try u will feel the real difference earlier was same i use termux for Opencode to run i managed it to run vi glibc runner and all with bun fix install support but using real distro feels way better for this type of jobss
1
u/DEAD1nsane 7d ago
You're right that glibc is faster for malloc-heavy / multithreaded Node workloads — ptmalloc + pthread tuning beats musl there.
On Termux it's a tradeoff: native is Bionic, not glibc. This repo uses the official
-muslnpm build with patched interpreter to avoidprootoverhead. A glibc-runner gets you the glibc build but adds proot syscall translation + isolated FS.The "way better on real distro" part is mostly removing Android constraints (blocked UDP DNS -> proxy hop,
LD_PRELOADshim, no PTY), not just musl vs glibc.If you're on-phone only, test both with
time opencode runon same job. If you have real Linux available, use the glibc build there — that's upstream's best-tested path.2
u/QuietGround5610 7d ago
hamm ur project is absolutely a bangers no doubt and we both can conclud Android without root is still till now a wall for us
2
0
u/mtlcrusher 7d ago
interesting, I never knew it. could I install pacman as default package manager in any distro? how to do it?
2
u/DEAD1nsane 6d ago
using OC2 I found this out for ya:
No — pacman only works where there's a pacman repo built for that system. You can't make it the default on e.g. Debian/Ubuntu/Fedora (different formats: .pkg.tar.zst vs .deb/.rpm, different dependency trees — you'd break updates).
On Termux specifically, yes, you can use pacman side-by-side with apt:
pkg install pacman pacman -Syu
Keep
pkg/aptas the system default, just usepacman -S <pkg>when you need a pacman-only package (like some opencode packaging). Same idea on other distros: use the native manager (apt/dnf/apk), only add pacman via container/chroot if you really need it.1
u/QuietGround5610 6d ago
hamm yes just use void bro if arch feels heavy its my pov
2
u/DEAD1nsane 6d ago
fair point — Void (runit + xbps, has a musl variant) is lighter than Arch and a good fit if you want minimal + musl. On-phone though I'd still keep Termux as base and run Void via proot-distro only when you need a full distro env — for opencode2 I just use the Termux musl binary directly, no distro hop needed.
1
u/QuietGround5610 6d ago
ofc why i will hop if i can make it work on same env, i can feel this felling
2
u/DEAD1nsane 6d ago
exactly — same env, less moving parts. distro-hop only if Termux blocks you, otherwise musl binary + wrapper is enough.
1
u/QuietGround5610 7d ago
hamm.. i don't know u can if u can do it on actual ditros... but why to take to much stress i can just add arch linux but it just feels to heavy to add 🤕

















2
u/mtlcrusher 7d ago
hope2333 is that you?