GuidesGetting started

OpenCode on Windows: install, WSL2, shell and paths

OpenCode 2 runs natively on Windows: install with npm or the zip, WinGet and Scoop, its PowerShell shell, port 28894, where its files live, WSL2, and common errors.

November 25, 2026Updated November 27, 2026The Everpod team
The short answer

OpenCode 2 runs natively on Windows, on x64 and ARM64 (2.4.2 as of November 26, 2026). Install it with npm install -g @opencode/cli from PowerShell, or download the Windows zip from opencode.ai/docs and put opencode.exe on your PATH. OpenCode’s docs say Windows package managers are not supported, though WinGet (Anomaly.OpenCode, at 2.4.1 on November 27) and Scoop’s main bucket (2.4.2) carry version 2; Chocolatey’s opencode is still version 1. Natively, OpenCode runs the agent’s commands in PowerShell 7 if it finds it, its background service listens on 127.0.0.1:28894 instead of 49374, and, going by its source, its files sit under your user profile in the same .config, .local and .cache folders as on Linux. Use WSL2 instead when your project and its tools are Linux ones.

Version 2 is native; version 1 pointed you to WSL

Version 1’s docs told Windows users to use WSL “for the best experience”, saying it “provides better performance and full compatibility with OpenCode’s features.” Version 2’s docs, at opencode.ai/docs since November 23, carry no such advice: they ship Windows builds of the command-line tool and the desktop app, and the npm package lists win32 among its platforms. Recent releases have been fixing Windows specifically, from Microsoft Store PowerShell support in 2.2.6 to taskbar progress and a stale-connection fix after sleep in 2.4.0.

Check which one you have with opencode --version: a bare number such as 1.19.6 is version 1, and a 2.x version such as 2.4.2 is version 2. The page at opencode.ai/docs/windows-wsl is still version 1’s and says so; its commands (opencode web, the opencode.ai/install script) install and run version 1.

Installing OpenCode 2 on Windows

RouteCommand or stepVersion it gives
npm (documented)
npm install -g @opencode/cli2.x
Zip download (documented)
x64, x64 baseline or ARM64 zip from the install page2.x
curl script, in Git Bash
curl -fsSL https://opencode.ai/v2/install | bash2.x
WinGet (not supported by the docs)
winget install --id Anomaly.OpenCode --exact2.x
Scoop (not supported by the docs)
scoop install opencode2.x
Chocolatey
choco install opencode1.19.6 (version 1)
npm, old package
npm install -g opencode-aiversion 1

npm is the route the docs give that works the same on every platform. The package’s postinstall script picks the native build for your machine from three Windows packages (x64, x64 baseline and ARM64), and it puts both opencode and an opencode2 alias on your PATH. pnpm, bun and yarn work the same way with the flags the install page shows.

The zip holds opencode.exe and nothing installs it for you: unzip it into a folder of your own and add that folder to your user PATH. The baseline build is for processors without AVX2; the installer script picks it by asking Windows whether the CPU has that feature, and WinGet’s x64 package uses the baseline zip for everyone.

The curl script is a bash script, and on Windows it runs only under Git Bash, MSYS2 or Cygwin (it recognises their MINGW, MSYS and CYGWIN names; in WSL it installs the Linux build instead). It puts opencode.exe in ~/.opencode/bin and adds that folder to PATH only in your bash startup file, such as ~/.bashrc, so PowerShell and Command Prompt will not find it until you add the folder to your Windows PATH yourself. On Windows on ARM, where Git Bash runs as emulated x64, it still installs the ARM64 build.

WinGet and Scoop packages exist, but the install page says plainly that “Windows package managers are not supported”, so npm or the zip is the supported route and these two sit outside it. The WinGet package, Anomaly.OpenCode (“OpenCode CLI”), is the one OpenCode’s own updater recognises: on a WinGet install, opencode upgrade calls WinGet for you. Scoop’s main-bucket manifest repackages the npm builds and follows the npm version. Chocolatey’s opencode package is version 1.19.6, so it installs the old version.

Coming from version 1? The migration page says to “remove a package-managed V1 installation before installing V2”, and opencode upgrade --major has no Chocolatey or Scoop route, so remove the Chocolatey or npm opencode-ai copy with its package manager first, then install version 2 as above. Avoid version 1’s own opencode uninstall for this, which deletes the data unless you pass --keep-data --keep-config: version 2 reads the same folders and imports version 1’s sessions and saved keys on first start; moving from OpenCode 1 to 2 covers the sessions that seem to go missing.

The shell it runs commands in

Natively, the agent’s commands run in a Windows shell, not bash. In 2.4.2’s source, with nothing configured OpenCode takes the first it finds of PowerShell 7 (pwsh), Windows PowerShell, Git Bash (found through where git is installed), and finally cmd.exe. To choose, set shell in your global opencode.json, which the config docs describe as “the shell used by the terminal and shell tools”:

{
  "shell": "bash"
}
Copied

On Windows a bare bash resolves to Git Bash first, so with Git for Windows installed this gives the agent a Unix shell on Windows paths; without it, OpenCode falls back to whatever bash is on your PATH, which may be WSL’s launcher. Quoting is where shells differ most. One report against version 1, not version 2 (#66449), shows the cost: the reporter says a model wrote a cmd /c rd /s /q line with \" escapes, which Windows PowerShell 5.1 does not treat as escapes, so rd got a bare \ and about 270,000 files were deleted from the root of the drive, with no permission rule set to ask first. Whatever shell you use, have destructive commands ask before they run, as OpenCode’s permission rules allow.

If you use PowerShell 7 from the Microsoft Store, be on 2.4.0 or later: Store PowerShell was supported from 2.2.6, multi-line commands were fixed in 2.2.7, and concurrent commands in 2.4.0.

The terminal

The CLI docs name no Windows terminal. They suggest Ghostty, WezTerm, Alacritty and Kitty, and note that a terminal with truecolor shows themes in their real colours while one without gets an approximation. Run opencode from a project folder in whichever terminal you use for PowerShell.

The background service on Windows: port 28894

OpenCode 2 starts one background server for your account, and every client, the terminal interface and the desktop app included, talks to it. OpenCode’s background service covers what it is and the opencode service commands. On Windows its default port differs. The web docs give 49374 for macOS, Linux and WSL and 28894 for Windows, because “Windows reserves ports from 49152 up, and WSL mirrored networking reserves another block below that.” A port reserved that way fails as in use while nothing is listening on it, the source notes, so OpenCode moves to the 28000s. It listens on localhost only:

opencode service status          # whether it runs, and on which address and port
opencode service set port 4096    # if something else holds the port
Copied

An OpenCode on Windows and another inside WSL are two separate services on two ports, with separate sessions, settings and saved keys.

Where OpenCode keeps its files on Windows

Apart from the machine-wide folder, the docs give only Unix-style paths. The table below is read from 2.4.2’s source, not from a Windows machine: OpenCode uses the XDG folders under your home directory on every platform, with no Windows branch, so on Windows they should land in your user profile, at the same relative paths as on Linux:

WhatWhere
Global config (opencode.json, cli.json, the service’s settings)
%USERPROFILE%\.config\opencode
Sessions and saved keys (opencode.db), logs
%USERPROFILE%\.local\share\opencode
The running service’s registration
%USERPROFILE%\.local\state\opencode\service.json
Cache
%USERPROFILE%\.cache\opencode
Machine-wide config
%ProgramData%\opencode
Scratch files
%TEMP%\opencode
Binary from the curl script
%USERPROFILE%\.opencode\bin (Git Bash’s ~)

The XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_STATE_HOME and XDG_CACHE_HOME variables move them on Windows too. opencode debug paths prints the paths your copy is actually using, so run it to confirm. WSL keeps its own set in the Linux home, under ~/.config/opencode and ~/.local/share/opencode.

OpenCode inside WSL2

In WSL2, OpenCode is the Linux program and everything on installing OpenCode on Linux applies, including the version 2 install line:

# inside your WSL distribution
curl -fsSL https://opencode.ai/v2/install | bash
Copied

Prefer WSL2 when the project builds with Linux tools, when your scripts and the model’s commands assume bash and Unix paths, or when you also deploy to Linux and want the agent to work in the same environment. Stay native when the project is a Windows one (.NET, PowerShell, Windows paths) or you want the desktop app to drive a local OpenCode with no networking between the two. Keep a WSL project in the Linux filesystem, such as ~/code, rather than under /mnt/c: OpenCode’s own WSL page gives that advice “for the smoothest experience”. Setting up WSL2 itself, the restart and the BIOS virtualisation setting, is in installing WSL2.

The desktop app on Windows

OpenCode Desktop has a Windows installer for x64 and ARM64 on the install page, and WinGet carries it as Anomaly.OpenCode.Desktop. 2.4.0 added Windows touches: the taskbar button shows session progress and flashes when a session needs you, the jump list has New Session and New Window, and Open in lists Windows Terminal. To work on a remote Linux server, the app uses your PC’s OpenSSH client and says “OpenSSH was not found.” if it is missing; the OpenCode Desktop guide covers that and the version matching it needs.

Problems Windows users hit

“Git Bash is required to update OpenCode”

On a copy installed with the curl script, opencode upgrade re-runs that script, and on Windows it runs it with Git Bash. When it cannot find one, it says “The OpenCode installer runs with Git Bash on Windows, and it was not found.” and suggests installing Git for Windows or pointing OPENCODE_GIT_BASH_PATH at bash.exe. A bare bash is deliberately not used, since on Windows it may be WSL’s launcher.

“Could not detect the installation method”

Could not detect the installation method. Update with your package manager or download the latest release.
Copied

OpenCode’s updater knows curl, npm, pnpm, bun, yarn, Vite+, Homebrew and WinGet. A zip you unzipped yourself is none of those, and Scoop is not on the list either: download the new zip, or run scoop update opencode.

Scoop: “The following instances of “opencode” are still running”

One open report (#65942, 2.3.2 to 2.4.1 from Scoop’s main bucket) has scoop update opencode refusing because an opencode.exe serve --service process, the background service, was still running after the terminal that started it had gone. The reporter force-stopped the opencode processes and the update went through; a bot reply suggested stopping the service first, which nobody on the issue has confirmed yet:

opencode service stop
scoop update opencode
Copied

The service will not start because the port is taken

The service fails with a message naming its port. Pick another with opencode service set port <port>; the service guide gives the message and how to find what holds the port.

“opencode-pty request timed out”

Reported on 2.3.0 (#65175, open, not reproduced): after hours of the background service running, the shell tool failed with this message in every session, restarting the OpenCode app did not help, and in the reporter’s words “A full Windows reboot fixed it immediately”. No maintainer has replied; a bot asked whether opencode service restart clears it; that is untested, but it is a cheaper thing to try than a reboot, on a current version.

Run OpenCode on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.