-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
Description
Environment
- Device: Android smartphone/tablet, HUAWEI PaperMate 11.5
- OS: Android (5.0+), HarmionyOS 4.2.0
- Terminal: Termux
- Arch:
aarch64(uname -m→aarch64) - Install method: official install script (
curl ... | sh, binary ends up in~/.opencode/bin/opencode)
Summary
After installing OpenCode on Termux using the official script, the Linux/aarch64 opencode binary does not start as a native Android executable.
- The binary requests a dynamic linker at
/lib/ld-linux-aarch64.so.1, which does not exist on Android/Termux. - After manually changing the interpreter to the correct Android linker, the binary fails with
Android 5.0 and later only support position-independent executables (-fPIE), which means it was not compiled as PIE and cannot be run on modern Android at all.
Steps to reproduce
- Install Termux from F‑Droid / Play Store.
- Update packages and install diagnostic tools:
pkg update -y pkg install -y file binutils patchelf
- Install OpenCode using the official method, for example:
curl -fsSL https://opencode.ai/install.sh | sh - Try to run the binary:
/data/data/com.termux/files/home/.opencode/bin/opencode
- Observe the shell error:
bash: /data/data/com.termux/files/home/.opencode/bin/opencode: cannot execute: required file not found
Diagnostics
-
Check the file type:
file /data/data/com.termux/files/home/.opencode/bin/opencode
The output shows a 64‑bit ELF for
aarch64, with the program interpreter set to/lib/ld-linux-aarch64.so.1(standard on many Linux distros, but not on Android/Termux). -
On Termux/Android,
/lib/ld-linux-aarch64.so.1does not exist.
To find the correct interpreter, I inspected a working Termux binary (bash):readelf -l "$(which bash)" | grep "Requesting program interpreter"
This reports
/system/bin/linker64as the requested program interpreter. -
I tried to “fix” the
opencodebinary by changing its interpreter:patchelf --set-interpreter /system/bin/linker64 \ /data/data/com.termux/files/home/.opencode/bin/opencode
This successfully changes the interpreter to the Android linker used by Termux.
-
Running
opencodeagain:/data/data/com.termux/files/home/.opencode/bin/opencode
Now I get a different error:
"/data/data/com.termux/files/home/.opencode/bin/opencode": error: Android 5.0 and later only support position-independent executables (-fPIE).This is the typical Android error when the ELF binary is not built as PIE. Since Android 5.0, only position‑independent executables (built with
-fPIE/-pie) are allowed to run.
What I expected
I expected the official Linux/aarch64 OpenCode binary to either:
- run natively under Termux on Android (with a correct interpreter and PIE build), or
- clearly be documented as not supported for native Termux/Android, with guidance to use a different build or a proot‑based Linux environment instead.
What actually happens
- With the unmodified binary:
bash: cannot execute: required file not founddue to the non‑existent/lib/ld-linux-aarch64.so.1. - After setting the interpreter to
/system/bin/linker64: the binary exits withAndroid 5.0 and later only support position-independent executables (-fPIE)and cannot be started at all. - This cannot be fixed on the user side by patching the existing ELF; it requires recompiling OpenCode with the correct flags and target.
Analysis / root cause
- The binary shipped by the installer appears to be a regular Linux ELF for
aarch64with glibc, requesting/lib/ld-linux-aarch64.so.1as interpreter. - Termux runs on Android, using
/system/bin/linker64and a different ABI, and Android ≥ 5.0 rejects non‑PIE executables. - Even after manually fixing the interpreter path, the OpenCode binary still cannot run, because it does not satisfy Android’s requirement for position‑independent executables.
Why this deserves a dedicated fix
- There are already reports about OpenCode issues on Termux (usually when running inside a proot‑distro like Ubuntu/Debian, with freezes, TUI issues, crashes on the second run, etc.), but those are runtime problems inside a Linux userland.
- In this case, the problem is more fundamental: the official Linux/aarch64 binary is simply incompatible with the native Android ABI (wrong interpreter and non‑PIE), so it is impossible to run it directly in Termux without a full Linux environment in proot.
Suggested fix
-
Provide an official Android/Termux build for
aarch64that:- is built as PIE (
-fPIE/-pie), - uses the correct interpreter for Android (for example
/system/bin/linker64, depending on the target ABI), - is tested in a real Termux environment, not only on standard Linux.
- is built as PIE (
-
Alternatively (until such a build exists), update the documentation and installer to:
- explicitly state that the current Linux/aarch64 binary is not intended to run natively on Termux/Android,
- recommend using OpenCode via a proot‑distro (Ubuntu/Debian) or a remote Linux server when working from Android.
Additional info
- I can attach exact outputs of
file,readelf -l, andpatchelf --print-interpreterif needed. - I’m happy to test any experimental Android/Termux builds (aarch64) and provide feedback.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response