Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Then run it with:
./packages/opencode/dist/opencode-<platform>/bin/opencode
```

Replace `<platform>` with your platform (e.g., `darwin-arm64`, `linux-x64`).
Replace `<platform>` with your platform (e.g., `darwin-arm64`, `linux-x64`, `android-arm64`).

- Core pieces:
- `packages/opencode`: OpenCode core business logic & server.
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ nix run nixpkgs#opencode # or github:anomalyco/opencode for latest dev
> [!TIP]
> Remove versions older than 0.1.x before installing.

#### Android/Termux

OpenCode can be installed on Android ARM64 devices using Termux:

```bash
# In Termux
curl -fsSL https://opencode.ai/install | bash
```

> [!NOTE]
> The Android build is based on the Linux ARM64 binary and may require proot-distro for full compatibility. Direct execution in Termux may have limitations due to Android's security model. For best results, consider using proot-distro with Alpine Linux.

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note recommends proot-distro with Alpine Linux, but the Android build is described as using the Linux ARM64 (glibc) binary. Alpine is musl-based, so the glibc binary likely won't run there without additional compatibility layers. Consider recommending a glibc-based proot distro (e.g., Debian/Ubuntu) or explicitly calling out the libc requirement.

Suggested change
> The Android build is based on the Linux ARM64 binary and may require proot-distro for full compatibility. Direct execution in Termux may have limitations due to Android's security model. For best results, consider using proot-distro with Alpine Linux.
> The Android build is based on the Linux ARM64 (glibc) binary and may require proot-distro for full compatibility. Direct execution in Termux may have limitations due to Android's security model. For best results, use proot-distro with a glibc-based Linux distribution (for example, Debian or Ubuntu). Musl-based distributions such as Alpine Linux are not supported without additional compatibility layers.

Copilot uses AI. Check for mistakes.

### Desktop App (BETA)

OpenCode is also available as a desktop application. Download directly from the [releases page](https://github.com/anomalyco/opencode/releases) or [opencode.ai/download](https://opencode.ai/download).
Expand Down
39 changes: 29 additions & 10 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,22 @@ if [ -n "$binary_path" ]; then
else
raw_os=$(uname -s)
os=$(echo "$raw_os" | tr '[:upper:]' '[:lower:]')

# Check if running on Android (e.g., Termux)
is_android=false
if [ -d /system/app ] && [ -d /system/priv-app ]; then
is_android=true
fi

case "$raw_os" in
Darwin*) os="darwin" ;;
Linux*) os="linux" ;;
Linux*)
if [ "$is_android" = "true" ]; then
os="android"
else
os="linux"
fi
;;
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
esac

Expand All @@ -101,16 +114,19 @@ else

combo="$os-$arch"
case "$combo" in
linux-x64|linux-arm64|darwin-x64|darwin-arm64|windows-x64)
linux-x64|linux-arm64|darwin-x64|darwin-arm64|windows-x64|android-arm64)
;;
*)
echo -e "${RED}Unsupported OS/Arch: $os/$arch${NC}"
if [ "$is_android" = "true" ] && [ "$arch" != "arm64" ]; then
echo -e "${MUTED}Note: OpenCode on Android/Termux currently only supports ARM64 architecture.${NC}"
fi
exit 1
;;
esac

archive_ext=".zip"
if [ "$os" = "linux" ]; then
if [ "$os" = "linux" ] || [ "$os" = "android" ]; then
archive_ext=".tar.gz"
fi
Comment on lines 128 to 131

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The installer treats os=android as a .tar.gz download and extracts it with tar -xzf. Currently, the build script will generate a .zip for opencode-android-arm64 unless the packaging logic is also updated (it only tars artifacts whose name contains "linux"). Ensure the build artifact extension matches this installer behavior, otherwise Android installs will fail at extraction time.

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -158,17 +174,20 @@ else
fi

target="$os-$arch"
if [ "$needs_baseline" = "true" ]; then
target="$target-baseline"
fi
if [ "$is_musl" = "true" ]; then
target="$target-musl"
# Android doesn't need baseline or musl variants
if [ "$os" != "android" ]; then
if [ "$needs_baseline" = "true" ]; then
target="$target-baseline"
fi
if [ "$is_musl" = "true" ]; then
target="$target-musl"
fi
fi

filename="$APP-$target$archive_ext"


if [ "$os" = "linux" ]; then
if [ "$os" = "linux" ] || [ "$os" = "android" ]; then
if ! command -v tar >/dev/null 2>&1; then
echo -e "${RED}Error: 'tar' is required but not installed.${NC}"
exit 1
Expand Down Expand Up @@ -334,7 +353,7 @@ download_and_install() {
curl -# -L -o "$tmp_dir/$filename" "$url"
fi

if [ "$os" = "linux" ]; then
if [ "$os" = "linux" ] || [ "$os" = "android" ]; then
tar -xzf "$tmp_dir/$filename" -C "$tmp_dir"
else
unzip -q "$tmp_dir/$filename" -d "$tmp_dir"
Expand Down
13 changes: 11 additions & 2 deletions packages/opencode/script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ const allTargets: {
arch: "arm64" | "x64"
abi?: "musl"
avx2?: false
android?: boolean
}[] = [
{
os: "linux",
arch: "arm64",
},
{
os: "linux",

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the Android target as { os: "linux", arch: "arm64", android: true } means --single builds on a Linux ARM64 host will now match both the regular linux-arm64 target and this Android target (same os/arch/abi/avx2), which conflicts with the intent of producing a single native binary. Consider excluding android: true targets from the --single selection unless an explicit flag is provided, or treat Android as its own os value in the selection logic.

Suggested change
os: "linux",
os: "android",

Copilot uses AI. Check for mistakes.
arch: "arm64",
android: true,
},
{
os: "linux",
arch: "x64",
Expand Down Expand Up @@ -146,7 +152,7 @@ for (const item of targets) {
const name = [
pkg.name,
// changing to win32 flags npm for some reason
item.os === "win32" ? "windows" : item.os,
item.os === "win32" ? "windows" : item.android ? "android" : item.os,
item.arch,
Comment on lines 152 to 156

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new android naming (opencode-android-arm64) will no longer match the release packaging condition later in this script that tars only keys containing "linux". As a result, the Android artifact will be produced as a .zip, but the installer/docs expect opencode-android-arm64.tar.gz, which will break installs. Update the packaging logic to treat the Android target like Linux for archive format (or otherwise keep the artifact extension consistent with the installer).

Copilot uses AI. Check for mistakes.
item.avx2 === false ? "baseline" : undefined,
item.abi === undefined ? undefined : item.abi,
Expand All @@ -163,6 +169,9 @@ for (const item of targets) {
const bunfsRoot = item.os === "win32" ? "B:/~BUN/root/" : "/$bunfs/root/"
const workerRelativePath = path.relative(dir, parserWorker).replaceAll("\\", "/")

// For Android, use the linux-arm64 target as Bun doesn't have native Android support
const buildTarget = item.android ? "bun-linux-arm64" : name.replace(pkg.name, "bun")

await Bun.build({
conditions: ["browser"],
tsconfig: "./tsconfig.json",
Expand All @@ -174,7 +183,7 @@ for (const item of targets) {
//@ts-ignore (bun types aren't up to date)
autoloadTsconfig: true,
autoloadPackageJson: true,
target: name.replace(pkg.name, "bun") as any,
target: buildTarget as any,
outfile: `dist/${name}/bin/opencode`,
execArgv: [`--user-agent=opencode/${Script.version}`, "--use-system-ca", "--"],
windows: {},
Expand Down
Loading