How to install OpenCode on Mac, Windows and Linux
Install OpenCode on macOS, Windows or Linux: the script, npm, Homebrew, Scoop or pacman, OpenCode 1 or 2, first run, updates, fixes, and OpenCode in Caprock.
To install OpenCode, run curl -fsSL https://opencode.ai/install | bash on macOS, Linux or WSL, or npm install -g opencode-ai on any system with Node.js. Then cd into a project, run opencode and add a model with /connect. opencode.ai's home page and OpenCode's README now offer OpenCode 2, a new major version with its own install command; the docs at opencode.ai/docs, the GitHub releases and the Windows package managers still install OpenCode 1. This page covers both, as read on 20 October 2026.
Install OpenCode on macOS
- 1
OpenCode's script
- 2
Or Homebrew, OpenCode's own tap
- 3
Or npm, with Node.js
- 4
Check it
The script downloads the build for your Mac from GitHub, picks the Intel build without AVX2 on an older Intel Mac, puts opencode in ~/.opencode/bin and adds that folder to your shell's rc file. Open a new terminal before you check. --no-modify-path leaves the rc file alone, and --version 1.18.34 installs an older release.
OpenCode recommends the tap over Homebrew's own formula. Plain brew install opencode is the core formula, which Homebrew builds from source: on 20 October it gave OpenCode 2.1.0, not OpenCode 1. Adding the tap does not change that; type the full name, anomalyco/tap/opencode.
Install OpenCode on Linux
- 1
Any distribution
- 2
Or npm, with Node.js
- 3
Or Homebrew on Linux
- 4
Arch, OpenCode 1 from the AUR
- 5
mise, OpenCode 1
On Linux the script also picks a musl build on Alpine and similar systems, and the build without AVX2 when /proc/cpuinfo does not list it. Plain mise use -g opencode gives OpenCode 2 on mise 2026.10.9 or later, and nix run nixpkgs#opencode gave OpenCode 2.0.32 on 20 October.
On Arch, sudo pacman -S opencode, which OpenCode's docs list as "Stable", installed OpenCode 2.1.1 from the extra repository on 20 October 2026. For OpenCode 1 on Arch, use opencode-bin from the AUR.
Copy and paste in the TUI needs a clipboard tool: xclip or xsel on X11, wl-clipboard on Wayland.
Install OpenCode on Windows
OpenCode's docs recommend WSL "for the best experience": install WSL, open its terminal and run the Linux script there. Your Windows files are under /mnt/c/; OpenCode suggests keeping the repository inside the WSL file system instead.
To run it natively:
- 1
Scoop
- 2
Or Chocolatey
- 3
Or npm, with Node.js
- 4
Or Docker
Scoop has x64 and ARM64 builds. The .zip builds on GitHub's releases page work without any manager; OpenCode's docs say installing with Bun on Windows is not supported yet. The curl script runs in Git Bash, x64 only.
OpenCode 1 or OpenCode 2
OpenCode 2 is a new major version, and on 20 October 2026 opencode.ai's home and download pages and OpenCode's README install it. OpenCode's docs at opencode.ai/docs, GitHub's latest release and the Windows package managers still install OpenCode 1.
| Install with | OpenCode 1 | OpenCode 2 |
|---|---|---|
| Script | opencode.ai/install | opencode.ai/v2/install |
| npm | opencode-ai | @opencode/cli |
| Homebrew | anomalyco/tap/opencode | anomalyco/tap/opencode-v2 |
| Arch | AUR opencode-bin | pacman -S opencode |
| Windows | Scoop, Chocolatey | npm, or a .zip |
| Version | 1.19.3, 16 October | 2.1.1, 20 October |
| Docs | opencode.ai/docs | opencode.ai/v2/docs |
Both install a command called opencode, and OpenCode 2's migration guide says not to keep them side by side: remove a package-managed OpenCode 1 first; the OpenCode 2 script replaces the OpenCode 1 binary. What changes:
- Plugins. OpenCode 1 plugins do not run in OpenCode 2; they need porting.
- The server API and its clients are new, so integrations that call OpenCode's server need porting too.
- Terminal settings move from
tui.jsonto one~/.config/opencode/cli.json, migrated on first start. - What carries over:
opencode.json, agents, commands, skills andAGENTS.mdare read from the same places. ACLAUDE.mdis not read as a fallback any more. - Windows: OpenCode 2's docs say Windows package managers are not supported, so Scoop and Chocolatey carry OpenCode 1 only. On Windows, OpenCode 2 comes from npm or a standalone
.zip, for x64, x64 without AVX2 (baseline) or ARM64.
OpenCode 2 also keeps sessions in a new session_v2 table, in the same opencode.db file.
First run: connect a model
- 1
Open a project
- 2
Start the TUI
- 3
Add a provider, inside the TUI
- 4
Write AGENTS.md for the project
OpenCode comes with a few free models, so it answers before you connect anything. /connect adds a provider: an API key from one of more than 75, OpenCode's own Zen or Go, or a subscription you sign in with — ChatGPT Plus or Pro, GitHub Copilot or GitLab Duo. A Claude Pro or Max plan is not one of them: OpenCode's providers page says Anthropic prohibits it. What each option costs is in OpenCode pricing.
Outside the TUI, opencode auth login does the same. OpenCode 1 keeps keys in ~/.local/share/opencode/auth.json. Tab switches between the build agent, which edits, and plan, which does not.
Where OpenCode keeps its files
The folders are the same on every system, Windows included: under your home folder, not AppData.
| Path | What it holds |
|---|---|
~/.local/share/opencode/ | sessions (opencode.db), auth.json, logs |
~/.config/opencode/ | opencode.json, plugins, agents |
~/.cache/opencode/ | provider packages OpenCode downloads |
Update OpenCode
opencode upgrade updates to the latest version, and opencode upgrade 1.18.34 to a given one. It detects how you installed it; --method names it when it guesses wrong. By default OpenCode 1 also downloads updates itself when it starts, unless a package manager installed it; "autoupdate": "notify" or false in opencode.json changes that.
| Installed with | Update |
|---|---|
| Script | opencode upgrade, or run the script again |
| Homebrew | brew upgrade anomalyco/tap/opencode |
| npm | npm install -g opencode-ai@latest |
| Scoop | scoop update opencode |
| Chocolatey | choco upgrade opencode |
| AUR | paru -Syu |
Uninstall OpenCode
opencode uninstall lists what it will remove and asks first. The two versions remove different things, which is worth knowing before you press enter. I ran --dry-run on both in a scratch home folder on 9 October:
- OpenCode 1 removes the binary and all four folders: data (your sessions and logins), cache, config and state. Add
--keep-data(-d) and--keep-config(-c) to keep them. - OpenCode 2 removes the cache only and keeps sessions, settings and state. An npm or Homebrew install is removed through that manager; a script install leaves the binary for you to delete.
A package-manager install comes out with that manager: brew uninstall opencode, npm uninstall -g opencode-ai, scoop uninstall opencode. OpenCode Desktop is removed like any other app.
Common install errors
opencode: command not foundafter the script. The script added~/.opencode/binto your rc file; the terminal you ran it in has not read it. Open a new one. The README listsOPENCODE_INSTALL_DIRandXDG_BIN_DIRto choose the folder, but the script served on 20 October reads neither and always uses~/.opencode/bin.- Windows: "not a valid application for this OS platform". npm left a 479-byte placeholder
opencode.exebecause the package'spostinstallstep did not run or was blocked. Issues #41370 and #36737, both closed now, describe it. The workarounds there: run the package'spostinstall.mjsby hand, ornpm install -g --allow-scripts=opencode-ai opencode-ai. Scoop avoids npm altogether. - "It seems your package manager failed to install the right opencode CLI package". npm's install step found no build for your platform, for example
opencode-linux-x64. The message names the packages to install by hand; issue #23601 hit an older wording of it on WSL2. illegal hardware instruction, or a silent hang. The default x64 build needs AVX2, which older CPUs lack (issues #8345 and #12553). The script picks the-baselinebuild on such machines, and so does npm's install step when it runs; it does not when install scripts are blocked, as with Bun without--trustor--ignore-scripts.- Windows Defender flags it as a trojan. Reported after an update through npm in issue #7655, closed in March 2026.
- The wrong version runs. Two installs, and whichever folder comes first on your PATH wins.
which -a opencodeon macOS and Linux,where opencodeon Windows, lists them; remove one. - OpenCode 2 on Windows. Open issues report a timeout waiting for its background service (#49034) and no in-place upgrade from PowerShell (#51755). Native Windows users may prefer OpenCode 1 from Scoop for now.
When something else fails, opencode --print-logs prints the log to the terminal, and the log files are in ~/.local/share/opencode/log/.
What it took on my Mac
- 9.5 s
- OpenCode 1.18.35 with its script
- 144 MB
- the one binary it leaves
- 186 MB
- OpenCode 2.0.26, same method
One run each on an Apple silicon Mac on 9 October 2026, into a scratch home folder; your network decides the time. npm install of opencode-ai took 7 seconds.
Run OpenCode in Caprock
Caprock is a free, open-source desktop app for macOS, Windows and Linux that records every coding agent on the machine and runs their own terminal programs in tabs. Once opencode is installed, New agent offers OpenCode next to Claude Code, Codex, Gemini CLI, Grok Build and Hermes Agent. Caprock finds the binary on your shell's PATH, in Homebrew's folders and in ~/.opencode/bin, where the script puts it, so a fresh install needs no setup.
- The OpenCode TUI in a tab, in the project you pick or a new worktree, with an optional model in OpenCode's
provider/modelform and a permission choice: Plan starts OpenCode'splanagent, Accept edits makes shell commands ask first. - Cost per session and per project. OpenCode computes each call's cost; Caprock reads it from OpenCode's database, read-only, and adds it to the same table as your Claude Code and Codex sessions. Like OpenCode's figure, it is modelled from list prices, not a bill.
- History from before Caprock. Sessions already in OpenCode's database show up, searchable beside Claude's, and an ended one continues in a new tab.
Caprock reads both versions: OpenCode 1's session table and OpenCode 2's session_v2, counting each message once in a database OpenCode 2 has upgraded. It starts OpenCode 1 with --port, -m and --agent, and OpenCode 2 with --standalone --session <id>, passing the model and agent through OPENCODE_CONFIG_CONTENT. Both are verified on macOS against real installs, and OpenCode 2 also in a Debian container on Linux; otherwise, on Windows and Linux, they are covered by Caprock's tests. More on running both in one window is in OpenCode desktop app.
Which install to pick
- The script — macOS, Linux or WSL, and you want
opencode upgradeto handle updates. - Homebrew's tap — you manage everything else with Homebrew.
- Scoop or Chocolatey — native Windows without Node.js.
- npm — Node.js is already there, or you pin versions per machine.
- OpenCode 2 — you want the new version and use no OpenCode 1 plugins.
- OpenCode with Claude Code and Codex in one record — install OpenCode 1 or 2, then install Caprock.
Questions people ask
- How do I install OpenCode?
- On macOS, Linux or WSL run curl -fsSL https://opencode.ai/install | bash. Anywhere Node.js runs, npm install -g opencode-ai. On a Mac, brew install anomalyco/tap/opencode; on Windows, scoop install opencode or choco install opencode.
- How do I install OpenCode on Windows?
- OpenCode recommends WSL: install it inside WSL with the script. Natively, use Scoop, Chocolatey or npm install -g opencode-ai. Scoop and Chocolatey carry OpenCode 1 only; OpenCode 2 comes from npm install -g @opencode/cli or a zip download.
- What is the difference between OpenCode 1 and OpenCode 2?
- OpenCode 2 is a new major version with its own package, @opencode/cli, and script, opencode.ai/v2/install. Plugins, the server API and terminal settings changed; your config and AGENTS.md carry over. Both install a command called opencode.
- How do I update OpenCode?
- Run opencode upgrade, or opencode upgrade <version> for a specific one. A package-manager install updates through that manager: brew upgrade, npm install -g opencode-ai@latest, scoop update opencode.
- How do I uninstall OpenCode?
- Run opencode uninstall. On OpenCode 1 it deletes your sessions and settings too unless you add --keep-data and --keep-config; --dry-run shows what it would remove. A package-manager install is removed with that manager.
- Can I use OpenCode with my Claude subscription?
- No. OpenCode's providers page says Anthropic prohibits using a Claude Pro or Max plan through OpenCode, and OpenCode stopped bundling those plugins in 1.3.0. Claude in OpenCode needs an Anthropic API key, OpenCode Zen, or another provider that serves Claude, such as Amazon Bedrock or OpenRouter.
Sources
- OpenCode docs — Intro: install, Windows, configure, initialize, mise for OpenCode 1 (OpenCode 1), read 20 October 2026
- OpenCode V2 docs — Intro: CLI install, standalone binaries, mise, "Windows package managers are not supported", read 20 October 2026
- OpenCode V2 docs — Migrate from V1: one opencode command, remove a package-managed V1 first, breaking changes, read 20 October 2026
- OpenCode — home and download pages, which install OpenCode 2 (opencode.ai/v2/install, @opencode/cli), read 20 October 2026
- OpenCode README — Installation: OpenCode 2 routes only (v2 script, @opencode/cli, the opencode-v2 tap, core formula, pacman, AUR opencode-beta, mise, nix), read 20 October 2026
- OpenCode install scripts as served on 20 October 2026: opencode.ai/install (OpenCode 1) and opencode.ai/v2/install (OpenCode 2)
- OpenCode on GitHub — latest release v1.19.3, 16 October 2026; tag v2.1.1, 20 October 2026; read 20 October 2026
- npm — opencode-ai, latest 1.19.3, read 20 October 2026
- npm — @opencode/cli, latest 2.1.1 (20 October 2026), read 20 October 2026
- Homebrew core — opencode formula, 2.1.0 built from source, read 20 October 2026
- anomalyco/homebrew-tap — opencode (1.19.3) and opencode-v2 (2.1.1), read 20 October 2026
- Arch Linux — extra/opencode 2.1.1, read 20 October 2026
- AUR — opencode-bin 1.19.3 and opencode-beta 2.1.1, read 20 October 2026
- Scoop Main bucket — opencode 1.19.3, read 20 October 2026
- Chocolatey — opencode 1.19.1, read 20 October 2026
- nixpkgs — opencode 2.0.32, OpenCode 2, read 20 October 2026
- OpenCode docs — CLI: auth, upgrade, uninstall, read 20 October 2026
- OpenCode docs — Providers: /connect, ChatGPT Plus/Pro, GitHub Copilot, the Anthropic note, read 20 October 2026
- OpenCode docs — Troubleshooting: logs, storage, uninstall, common issues, Linux clipboard, read 20 October 2026
- OpenCode docs — Windows (WSL), read 20 October 2026
- OpenCode source — OpenCode 2 keeps sessions in the session_v2 table (packages/core/src/session/sql.ts at v2.0.26)
- anomalyco/opencode issue #41370 — Windows: npm postinstall leaves a 479-byte stub, opened 9 August 2026, closed 11 October 2026
- anomalyco/opencode issue #36737 — Windows: 479-byte placeholder opencode.exe when postinstall is blocked, opened 13 July 2026, closed
- anomalyco/opencode issue #23601 — WSL2: "package manager failed to install the right version", opened 20 April 2026, closed 15 July 2026
- anomalyco/opencode issue #8345 — zsh: illegal hardware instruction, opened 14 January 2026, closed 11 October 2026
- anomalyco/opencode issue #12553 — Windows: CPUs without AVX2 need the baseline binary, opened 7 February 2026, closed 19 July 2026
- anomalyco/opencode issue #7655 — npm install flagged as a trojan by Windows Defender, opened 10 January 2026, closed 28 March 2026
- anomalyco/opencode issue #49034 — OpenCode 2 on Windows times out waiting for the background service, opened 14 September 2026, open on 20 October 2026
- anomalyco/opencode issue #51755 — OpenCode 2 installed from PowerShell cannot be upgraded in place, opened 28 September 2026, open on 20 October 2026
- Caprock source — where Caprock looks for the opencode binary, ~/.opencode/bin included (internal/agents/binaries.go)
- Caprock source — how an OpenCode session is started (internal/agents/argv.go)
- Caprock source — reading OpenCode's session table (internal/opencode/opencode.go)
- Caprock spec — OpenCode support, OpenCode 1 and 2 (.ai/16-opencode.md)
- Caprock README — OpenCode, Codex and DeepSeek Harness: verified on macOS, tests on Linux and Windows
- Caprock changelog — 0.93.1: OpenCode 2 verified on Linux in a container; 0.99.0 Grok Build and 0.122.0 Hermes Agent in New agent
Try it
The record of every coding agent you run, the sessions it did not start included. Free, open source; nothing leaves your machine.
Notarized by Apple. One file for Apple silicon and Intel, macOS 13 or later.
Or run it yourself:
Paste in Terminal: it installs Caprock and opens it.Or with Homebrew: brew install --cask dspv/tap/caprock-app