Fails to install on Android (Termux)

Resolved 💬 17 comments Opened Aug 30, 2025 by igorgatis Closed Sep 25, 2025
💡 Likely answer: A maintainer (bolinfest, collaborator) responded on this thread — see the highlighted reply below.

What version of Codex is running?

_No response_

Which model were you using?

_No response_

What platform is your computer?

Linux 6.1.124-android14-11-g8d713f9e8e7b-ab13202960 aarch64 unknown

What steps can reproduce the bug?

Install termux on a android phone. Open tmux and run:

npm i -g @openai/codex

What is the expected behavior?

_No response_

What do you see instead?

> @vscode/ripgrep@1.15.14 postinstall
> node ./lib/postinstall.js

Unhandled rejection:  Promise {
  <rejected> Error: Unknown platform: android
      at getTarget (/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/node_modules/@vscode/ripgrep/lib/postinstall.js:49:24)
      at main (/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/node_modules/@vscode/ripgrep/lib/postinstall.js:104:26)
} reason: Error: Unknown platform: android
    at getTarget (/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/node_modules/@vscode/ripgrep/lib/postinstall.js:49:24)
    at main (/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/node_modules/@vscode/ripgrep/lib/postinstall.js:104:26)

Additional information

Possible fix https://github.com/microsoft/vscode-ripgrep/issues/76

View original on GitHub ↗

17 Comments

myudak · 10 months ago

Exact same thing, also i cant login with gpt plus, even with copying the auth.json still error

⚠️ stream error: error sending request for url (https://chatgpt.com/backend-api/codex/responses); retrying 1/5
in 215ms…
bolinfest collaborator · 10 months ago

Hmm, I think https://github.com/openai/codex/pull/3660 should fix this once we cut a release with it?

This workflow from that PR:

https://github.com/openai/codex/actions/runs/17961595388/job/51085840022?pr=3660

Wrote the test build of the npm package to:

https://github.com/openai/codex/actions/runs/17961595388/artifacts/4088342212

If you could verify that works for you on Termux, I'd appreciate it!

KyongSik-Yoon · 10 months ago

install failed on termux

~ ❯❯❯ npm i -g @openai/codex ✘ 1

@vscode/ripgrep@1.15.14 postinstall node ./lib/postinstall.js

Unhandled rejection: Promise {
<rejected> Error: Unknown platform: android
at getTarget (/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/node_modules/@vscode/ripgrep/lib/postinstall.js:49:24)
at main (/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/node_modules/@vscode/ripgrep/lib/postinstall.js:104:26)
} reason: Error: Unknown platform: android
at getTarget (/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/node_modules/@vscode/ripgrep/lib/postinstall.js:49:24)
at main (/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/node_modules/@vscode/ripgrep/lib/postinstall.js:104:26)

changed 11 packages in 4s

bolinfest collaborator · 9 months ago

@KyongSik-Yoon The PR is not merged yet, and even once it has, you will have wait until we cut a new release that uses it. I am asking you to download the version at https://github.com/openai/codex/actions/runs/17961595388/artifacts/4088342212 and to run it directly.

bolinfest collaborator · 9 months ago

For the moment, you can also try:

npm install -g @openai/codex@0.41.0-alpha.1

though I would uninstall it once we have an official 0.41.0 release and then stick with:

npm install -g @openai/codex
bolinfest collaborator · 9 months ago

@KyongSik-Yoon @myudak @igorgatis 0.41.0 is out with the fix, so please try now and report back: https://www.npmjs.com/package/@openai/codex

myudak · 9 months ago
@KyongSik-Yoon @myudak @igorgatis 0.41.0 is out with the fix, so please try now and report back: https://www.npmjs.com/package/@openai/codex

Whats changed on that version can i still login with chatgpt account on termux without the browser gui? or paste the token etc

bolinfest collaborator · 9 months ago
bolinfest collaborator · 9 months ago

@myudak It sounds like this specific issue is resolved, so closing.

igorgatis · 9 months ago

Not sure what I'm doing wrong. I'm getting:

$ npm i -g @openai/codex

added 1 package in 4s
$ codex
error: "/data/data/com.termux/files/usr/lib/node_modules/@openai/codex/vendor/aarch64-unknown-linux-musl/codex/codex" has unexpected e_type: 2
stableversion · 9 months ago

@myudak The reason you get ``⚠️ stream error: error sending request for url`` is because codex bin is using musl. Simply build codex-rs yourself and it will work.

bolinfest collaborator · 9 months ago

@myudak We do build x86_64 binaries for Linux, but it is hard to distribute those in a way that "just works" for everyone since it depends on your libc.

Termux is Debian based? How many versions of Debian would we have to build for to make this all work?

stableversion · 9 months ago

@bolinfest Termux is bionic libc and (usually) aarch64 when you run ``npm install -g @openai/codex`` it installs the aarch64 linux musl version of codex-rs on termux, (if you trace the wrapper) which somehow works enough to launch, but different enough from bionic that certain network operations don't work.

Building codex-rs yourself works fine, someone should just package it for termux.

guspix · 8 months ago
Building codex-rs yourself works fine

For anyone interested in doing this, make sure you have cargo installed with pkg install rust and all packages upgraded with pkg upgrade (I ran into version mismatch issues with cargo and llvm before upgrading), then you can download and compile codex with this command:

cargo install --git https://github.com/openai/codex --tag rust-v0.50.0 codex-cli --force --locked

This command will install version 0.50.0, change the version number in the command to install some other version.

In my low end android phone this command actually took almost half an hour to run, ran out of memory and failed, so I created a cargo profile that used less memory at build time by creating the following file in ~/.cargo/config.toml:

[profile.termux]
inherits = "release"
lto = "off"
codegen-units = 8
opt-level = "s"

Then I used that profile like this:

cargo install --git https://github.com/openai/codex --tag rust-v0.50.0 codex-cli --force --locked --profile termux

This was enough for codex cli to build and run well in my phone, just make sure your cargo bin directory is in your path and it should work. Even the ChatGPT Plus login worked well in termux, I didn't have to use the instructions for headless environments.

robertkirkman · 8 months ago
Termux is Debian based? How many versions of Debian would we have to build for to make this all work?

If you would like to support Android/Termux in the upstream of your project, one option that might be convenient for you is to use the termux-docker Docker image inside GitHub Actions using a technique like this:

https://github.com/robertkirkman/termux-on-gha/blob/master/.github/workflows/build-and-test.yml

termux-docker manipulates the form of Android into a shape that may be familiar to users of distros like Debian which have apt install.

however, cross-compiling the project using the official Android NDK is another option that is a bit more conventional among Android projects.

The resulting binaries from either method would tend to work in not only Termux, but also most likely in other terminal emulator apps for Android as well.

~~I must mention that currently, the termux-docker image in DockerHub unfortunately has the problem that it contains some precompiled binaries of unverified origin, so its current version might be inappropriate for use in the CI of a high-profile project like this for that reason. This PR removes all unverified precompiled binaries from the image and replaces all of them with binaries fetched from a source which compiled them inside GitHub Actions with verifiable logs, so when it is merged that will be resolved:~~

EDIT: merged now! termux-docker is now built transparently in the open.

lazybabyz · 8 months ago
> Building codex-rs yourself works fine For anyone interested in doing this, make sure you have cargo installed with pkg install rust and all packages upgraded with pkg upgrade (I ran into version mismatch issues with cargo and llvm before upgrading), then you can download and compile codex with this command: cargo install --git https://github.com/openai/codex --tag rust-v0.50.0 codex-cli --force --locked This command will install version 0.50.0, change the version number in the command to install some other version. In my low end android phone this command actually took almost half an hour to run, ran out of memory and failed, so I created a cargo profile that used less memory at build time by creating the following file in ~/.cargo/config.toml: [profile.termux] inherits = "release" lto = "off" codegen-units = 8 opt-level = "s" Then I used that profile like this: cargo install --git https://github.com/openai/codex --tag rust-v0.50.0 codex-cli --force --locked --profile termux This was enough for codex cli to build and run well in my phone, just make sure your cargo bin directory is in your path and it should work. Even the ChatGPT Plus login worked well in termux, I didn't have to use the instructions for headless environments.

Thanks U Guspix,
After I clicked Sign in with ChatGPT I got the following error:

The application panicked (crashed).
Message: android context was not initialized
Location: /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ndk-context-0.1.1/src/lib.rs:72

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

chatgpt said:
When logging into ChatGPT using a browser, Codex attempts to use the Android NDK's embedded context (using the ndk-context path). In an environment like Termux, which lacks native Android Activity, this context doesn't exist, causing a panic.

anyway,i use Windows auth.json login information to termux:
mkdir -p "$HOME/.codex"
cat > "$HOME/.codex/auth.json"
chmod 600 "$HOME/.codex/auth.json"
ls -l "$HOME/.codex/auth.json"

netanel-haber · 3 months ago

https://gist.github.com/netanel-haber/77b91c4148249394d75546348bae7698
Headless wasn't working on termux, the changes I suggest here fix the headless flow without the need to build from scratch (tested on npm install)