copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

Android/Termux support broken in v1.0.48+ (runtime.node requires glibc)

Open hasankhan opened this issue 6 months ago • 6 comments

Summary

Copilot CLI v1.0.48 introduced a native Rust addon (runtime.node) that is compiled against glibc, making it impossible to run on Android/Termux where Node.js uses Bionic libc.

Environment

  • Platform: Android (Termux)
  • process.platform: "android"
  • process.arch: "arm64"
  • Node.js: v24.x (Termux package)
  • Last working version: 1.0.45

Issues by version

v1.0.45 (workable with patches)

Three fixable issues:

  1. ripgrep: Looks for ripgrep/bin/android-arm64/rg — fixed by copying from linux-arm64/rg (statically linked, runs fine)
  2. pty.node: Looks for prebuilds/android-arm64/pty.node — fixed by building node-pty from source on Termux
  3. Platform switch: The native module loader in app.js/index.js/sdk/index.js doesn't handle case "android" — fixed by patching the JS

v1.0.48+ (BROKEN — no workaround)

A new runtime.node Rust addon was introduced that handles token counting (tiktoken), MCP config parsing, shell analysis, hooks, and session filesystem. It is linked against glibc:

NEEDED: libgcc_s.so.1, libpthread.so.0, libm.so.6, libdl.so.2, libc.so.6

This cannot run on Android because:

  • Android uses Bionic libc, not glibc
  • The glibc TLS (Thread-Local Storage) model is incompatible with Android's linker
  • You cannot mix glibc and Bionic libraries in the same process
  • The binary is closed-source Rust, so we cannot rebuild it

Request

  1. Ship an Android-compatible runtime.node — Rust supports the aarch64-linux-android target natively. Cross-compiling with cargo build --target aarch64-linux-android would produce a Bionic-compatible binary.

  2. Add android-arm64 to the platform matrix — The optional dependencies (@github/copilot-linux-arm64, etc.) should include an @github/copilot-android-arm64 variant.

  3. Handle "android" in the platform switch — The JS code in app.js, index.js, and sdk/index.js should map process.platform === "android" to the appropriate prebuild path.

Workaround

We are pinned to v1.0.45. Users who accidentally upgrade are stuck.

Additional context

Termux is a widely-used terminal emulator for Android that provides a Linux-like environment. Node.js runs natively on it. Before v1.0.48, Copilot CLI worked with minor patches. The introduction of the glibc-only native addon broke this entirely.

hasankhan avatar May 15 '26 07:05 hasankhan

Running into the same situation

arsdragonfly avatar May 17 '26 04:05 arsdragonfly

Termux has alreadly a patched glibc, use that env so you can use normal aach64 linux gnu packages.

Image

The one i installed with my patched mise was the wrong one. mise doesnt provide it yet. But we can install the real one with npm directly on termux no proot needed, thanks to the patched termux glibc.

Image

wiilwaalka avatar May 17 '26 14:05 wiilwaalka

Workaround: glibc wrapper (no proot needed)

Building on the glibc approach mentioned above — here's a complete workaround that runs Copilot CLI v1.0.48+ on Termux without proot or a full glibc shell.

Idea: Download an official linux-arm64 Node.js binary and launch it via glibc's ld-linux-aarch64.so.1. This makes process.platform === "linux" so runtime.node loads normally.

Prerequisites

pkg install glibc-repo
pkg install glibc-runner
npm install -g @github/copilot

1. Download linux-arm64 Node.js

NODE_VERSION="v24.14.1"
NODE_DIR="$HOME/node-linux"
mkdir -p "$NODE_DIR"
curl -sL "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-arm64.tar.xz" \
  | tar xJ -C "$NODE_DIR/"
mv "$NODE_DIR/node-${NODE_VERSION}-linux-arm64" "$NODE_DIR/${NODE_VERSION}"

2. Create node-wrapper (fixes child_process.fork)

When node runs under ld.so, process.execPath points to ld-linux-aarch64.so.1 instead of node. This breaks child_process.fork() in interactive mode. The wrapper fixes this:

cat > "$NODE_DIR/$NODE_VERSION/bin/node-wrapper" << 'EOF'
#!/data/data/com.termux/files/usr/bin/bash
GLIBC_PREFIX="/data/data/com.termux/files/usr/glibc"
REAL_NODE="$(dirname "$0")/node"
LD_SO="$GLIBC_PREFIX/lib/ld-linux-aarch64.so.1"
export PATH="$GLIBC_PREFIX/bin:$PATH"
unset LD_PRELOAD
exec "$LD_SO" "$REAL_NODE" "$@"
EOF
chmod +x "$NODE_DIR/$NODE_VERSION/bin/node-wrapper"

3. Create preload script (fixes process.execPath)

cat > "$NODE_DIR/$NODE_VERSION/copilot-preload.js" << 'EOF'
const path = require('path');
const wrapperPath = path.join(__dirname, 'bin', 'node-wrapper');
Object.defineProperty(process, 'execPath', { value: wrapperPath, writable: true, configurable: true });
if (process.argv[0] && process.argv[0].includes('ld-linux-aarch64')) {
  process.argv[0] = wrapperPath;
}
EOF

4. Create copilot wrapper

rm -f "$PREFIX/bin/copilot"
cat > "$PREFIX/bin/copilot" << 'EOF'
#!/data/data/com.termux/files/usr/bin/bash
export SSL_CERT_FILE="/data/data/com.termux/files/usr/etc/tls/cert.pem"
export SSL_CERT_DIR="/data/data/com.termux/files/usr/etc/tls/certs"
export NODE_EXTRA_CA_CERTS="/data/data/com.termux/files/usr/etc/tls/cert.pem"
export NODE_OPTIONS="--no-warnings"
GLIBC_PREFIX="/data/data/com.termux/files/usr/glibc"
NODE_LINUX_DIR="$HOME/node-linux/v24.14.1"
LINUX_NODE="$NODE_LINUX_DIR/bin/node"
PRELOAD="$NODE_LINUX_DIR/copilot-preload.js"
COPILOT="/data/data/com.termux/files/usr/lib/node_modules/@github/copilot/npm-loader.js"
LD_SO="$GLIBC_PREFIX/lib/ld-linux-aarch64.so.1"
export PATH="$GLIBC_PREFIX/bin:$PATH"
unset LD_PRELOAD
exec "$LD_SO" "$LINUX_NODE" -r "$PRELOAD" "$COPILOT" "$@"
EOF
chmod +x "$PREFIX/bin/copilot"

Verify

copilot --version   # GitHub Copilot CLI 1.0.48
copilot             # interactive mode works too

Note: After npm update -g @github/copilot, you need to re-create the wrapper (step 4) since npm overwrites it with a symlink.

hasankhan avatar May 17 '26 20:05 hasankhan

Update: Additional fix needed for bash tool (v1.0.52+)

Even with the glibc wrapper working, the bash tool (PTY shell spawning) fails silently with "Failed to start bash process" on Termux.

Root cause: The shell path is hardcoded as /bin/bash in app.js (line ~5828) and sdk/index.js:

// app.js — inside lke.create() static method
let u = l ? c : "/bin/bash";

On Termux, bash is at $PREFIX/bin/bash (/data/data/com.termux/files/usr/bin/bash), so pty.fork("/bin/bash", ...) fails because the binary does not exist.

Fix: Patch both files to use process.env.SHELL with fallback:

COPILOT_DIR="$(npm root -g)/@github/copilot"
sed -i 's|?c:"/bin/bash"|?c:(process.env.SHELL\|\|"/bin/bash")|' "$COPILOT_DIR/app.js"
sed -i 's|?l:"/bin/bash"|?l:(process.env.SHELL\|\|"/bin/bash")|' "$COPILOT_DIR/sdk/index.js"

This must be re-applied after every npm update since it overwrites the files.

Suggestion to maintainers: Replace the hardcoded /bin/bash with process.env.SHELL || "/bin/bash" upstream. This is a one-line fix that would make the bash tool work on any non-standard Linux environment (Termux, NixOS, custom containers, etc.).

hasankhan avatar May 23 '26 10:05 hasankhan

Workaround: glibc wrapper (no proot needed)

Building on the glibc approach mentioned above — here's a complete workaround that runs Copilot CLI v1.0.48+ on Termux without proot or a full glibc shell.

Idea: Download an official linux-arm64 Node.js binary and launch it via glibc's ld-linux-aarch64.so.1. This makes process.platform === "linux" so runtime.node loads normally.

Prerequisites

pkg install glibc-repo pkg install glibc-runner npm install -g @github/copilot

1. Download linux-arm64 Node.js

NODE_VERSION="v24.14.1" NODE_DIR="$HOME/node-linux" mkdir -p "$NODE_DIR" curl -sL "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-arm64.tar.xz"
| tar xJ -C "$NODE_DIR/" mv "$NODE_DIR/node-${NODE_VERSION}-linux-arm64" "$NODE_DIR/${NODE_VERSION}"

2. Create node-wrapper (fixes child_process.fork)

When node runs under ld.so, process.execPath points to ld-linux-aarch64.so.1 instead of node. This breaks child_process.fork() in interactive mode. The wrapper fixes this:

cat > "$NODE_DIR/$NODE_VERSION/bin/node-wrapper" << 'EOF' #!/data/data/com.termux/files/usr/bin/bash GLIBC_PREFIX="/data/data/com.termux/files/usr/glibc" REAL_NODE="$(dirname "$0")/node" LD_SO="$GLIBC_PREFIX/lib/ld-linux-aarch64.so.1" export PATH="$GLIBC_PREFIX/bin:$PATH" unset LD_PRELOAD exec "$LD_SO" "$REAL_NODE" "$@" EOF chmod +x "$NODE_DIR/$NODE_VERSION/bin/node-wrapper"

3. Create preload script (fixes process.execPath)

cat > "$NODE_DIR/$NODE_VERSION/copilot-preload.js" << 'EOF' const path = require('path'); const wrapperPath = path.join(__dirname, 'bin', 'node-wrapper'); Object.defineProperty(process, 'execPath', { value: wrapperPath, writable: true, configurable: true }); if (process.argv[0] && process.argv[0].includes('ld-linux-aarch64')) { process.argv[0] = wrapperPath; } EOF

4. Create copilot wrapper

rm -f "$PREFIX/bin/copilot" cat > "$PREFIX/bin/copilot" << 'EOF' #!/data/data/com.termux/files/usr/bin/bash export SSL_CERT_FILE="/data/data/com.termux/files/usr/etc/tls/cert.pem" export SSL_CERT_DIR="/data/data/com.termux/files/usr/etc/tls/certs" export NODE_EXTRA_CA_CERTS="/data/data/com.termux/files/usr/etc/tls/cert.pem" export NODE_OPTIONS="--no-warnings" GLIBC_PREFIX="/data/data/com.termux/files/usr/glibc" NODE_LINUX_DIR="$HOME/node-linux/v24.14.1" LINUX_NODE="$NODE_LINUX_DIR/bin/node" PRELOAD="$NODE_LINUX_DIR/copilot-preload.js" COPILOT="/data/data/com.termux/files/usr/lib/node_modules/@github/copilot/npm-loader.js" LD_SO="$GLIBC_PREFIX/lib/ld-linux-aarch64.so.1" export PATH="$GLIBC_PREFIX/bin:$PATH" unset LD_PRELOAD exec "$LD_SO" "$LINUX_NODE" -r "$PRELOAD" "$COPILOT" "$@" EOF chmod +x "$PREFIX/bin/copilot"

Verify

copilot --version # GitHub Copilot CLI 1.0.48 copilot # interactive mode works too Note: After npm update -g @github/copilot, you need to re-create the wrapper (step 4) since npm overwrites it with a symlink.

Working Thanks

AminSiddika avatar May 24 '26 19:05 AminSiddika

Is a fix planned? I'd love to be able to run Copilot CLI from Termux on my phone!

demccormack avatar Nov 05 '26 21:11 demccormack