OpenCode binary fails to run natively on Termux / Android aarch64 (wrong interpreter + non‑PIE executable) #7516

Open
opened 2026-02-16 18:07:25 -05:00 by yindo · 3 comments
Owner

Originally created by @ivannin on GitHub (Jan 25, 2026).

Originally assigned to: @thdxr on GitHub.

Description

Environment

  • Device: Android smartphone/tablet, HUAWEI PaperMate 11.5
  • OS: Android (5.0+), HarmionyOS 4.2.0
  • Terminal: Termux
  • Arch: aarch64 (uname -maarch64)
  • 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.

  1. The binary requests a dynamic linker at /lib/ld-linux-aarch64.so.1, which does not exist on Android/Termux.
  2. 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

  1. Install Termux from F‑Droid / Play Store.
  2. Update packages and install diagnostic tools:
    pkg update -y
    pkg install -y file binutils patchelf
    
  3. Install OpenCode using the official method, for example:
    curl -fsSL https://opencode.ai/install.sh | sh
    
  4. Try to run the binary:
    /data/data/com.termux/files/home/.opencode/bin/opencode
    
  5. Observe the shell error:
    bash: /data/data/com.termux/files/home/.opencode/bin/opencode: cannot execute: required file not found
    

Diagnostics

  1. 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).

  2. On Termux/Android, /lib/ld-linux-aarch64.so.1 does 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/linker64 as the requested program interpreter.

  3. I tried to “fix” the opencode binary 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.

  4. Running opencode again:

    /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 found due to the non‑existent /lib/ld-linux-aarch64.so.1.
  • After setting the interpreter to /system/bin/linker64: the binary exits with Android 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 aarch64 with glibc, requesting /lib/ld-linux-aarch64.so.1 as interpreter.
  • Termux runs on Android, using /system/bin/linker64 and 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

  1. Provide an official Android/Termux build for aarch64 that:

    • 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.
  2. 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, and patchelf --print-interpreter if 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

Originally created by @ivannin on GitHub (Jan 25, 2026). Originally assigned to: @thdxr on GitHub. ### 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. 1) The binary requests a dynamic linker at `/lib/ld-linux-aarch64.so.1`, which does not exist on Android/Termux. 2) 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** 1. Install Termux from F‑Droid / Play Store. 2. Update packages and install diagnostic tools: ```bash pkg update -y pkg install -y file binutils patchelf ``` 3. Install OpenCode using the official method, for example: ```bash curl -fsSL https://opencode.ai/install.sh | sh ``` 4. Try to run the binary: ```bash /data/data/com.termux/files/home/.opencode/bin/opencode ``` 5. Observe the shell error: ```bash bash: /data/data/com.termux/files/home/.opencode/bin/opencode: cannot execute: required file not found ``` **Diagnostics** 1. Check the file type: ```bash 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). 2. On Termux/Android, `/lib/ld-linux-aarch64.so.1` does not exist. To find the correct interpreter, I inspected a working Termux binary (`bash`): ```bash readelf -l "$(which bash)" | grep "Requesting program interpreter" ``` This reports `/system/bin/linker64` as the requested program interpreter. 3. I tried to “fix” the `opencode` binary by changing its interpreter: ```bash 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. 4. Running `opencode` again: ```bash /data/data/com.termux/files/home/.opencode/bin/opencode ``` Now I get a different error: ```text "/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 found` due to the non‑existent `/lib/ld-linux-aarch64.so.1`. - After setting the interpreter to `/system/bin/linker64`: the binary exits with `Android 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 `aarch64` with glibc, requesting `/lib/ld-linux-aarch64.so.1` as interpreter. - Termux runs on Android, using `/system/bin/linker64` and 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** 1. Provide an official Android/Termux build for `aarch64` that: - 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. 2. 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`, and `patchelf --print-interpreter` if 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_
yindo added the bug label 2026-02-16 18:07:25 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 25, 2026):

This issue might be a duplicate of or closely related to existing issues. Please check:

  • #961: Termux support feature request
  • #709: "bash: cannot execute: required file not found" error in Termux (same error message as #10504)
  • #7472: OpenCode crashes with "Aborted" on Termux/Debian on second attempt
  • #8620: [Regression] v1.1.21 OpenTUI fails to initialize in Termux/PRoot (ARM64) - binary loading issues
  • #3143: OpenCode crashes on second run in Termux/Proot distro
  • #8959: OpenCode freezes with black screen in Termux proot-distro Ubuntu
  • #9223: Installation/runtime issues in Debian on Termux
  • #7843: Critical deadlock on Linux ARM64 in containerized environments
  • #1657: OpenCode crashes on NVIDIA GH200 (ARM/aarch64)
  • #8086: OpenCode crashes with Aborted on NVIDIA GH200 (aarch64)

This appears to be the root cause of several related issues in #7472, #3143, #7843, #8620, and others that manifest as crashes or hangs on ARM64/aarch64 systems and Termux environments.

Feel free to ignore if this addresses a unique aspect of the Termux/Android compatibility not covered by these issues.

@github-actions[bot] commented on GitHub (Jan 25, 2026): This issue might be a duplicate of or closely related to existing issues. Please check: - #961: Termux support feature request - #709: "bash: cannot execute: required file not found" error in Termux (same error message as #10504) - #7472: OpenCode crashes with "Aborted" on Termux/Debian on second attempt - #8620: [Regression] v1.1.21 OpenTUI fails to initialize in Termux/PRoot (ARM64) - binary loading issues - #3143: OpenCode crashes on second run in Termux/Proot distro - #8959: OpenCode freezes with black screen in Termux proot-distro Ubuntu - #9223: Installation/runtime issues in Debian on Termux - #7843: Critical deadlock on Linux ARM64 in containerized environments - #1657: OpenCode crashes on NVIDIA GH200 (ARM/aarch64) - #8086: OpenCode crashes with Aborted on NVIDIA GH200 (aarch64) This appears to be the root cause of several related issues in #7472, #3143, #7843, #8620, and others that manifest as crashes or hangs on ARM64/aarch64 systems and Termux environments. Feel free to ignore if this addresses a unique aspect of the Termux/Android compatibility not covered by these issues.
Author
Owner

@Nsomnia commented on GitHub (Feb 3, 2026):

Indeed. Proot install works but only for one launch which I gotat figure out now.

@Nsomnia commented on GitHub (Feb 3, 2026): Indeed. Proot install works but only for one launch which I gotat figure out now.
Author
Owner

@gitawego commented on GitHub (Feb 14, 2026):

Same issue here

@gitawego commented on GitHub (Feb 14, 2026): Same issue here
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7516