opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Windows Support

Open thdxr opened this issue 5 months ago • 153 comments

our windows support isn't really there - creating this one super issue to track all problems

thdxr avatar Jul 03 '25 03:07 thdxr

here is how it works for me

  1. Install Chocolatey Open PowerShell as administrator. Run the following command to relax the execution policy so the installation script can run:

Set-ExecutionPolicy Bypass -Scope Process -Force

Now run the official Chocolatey installation command:

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

  1. Install the missing tools with Chocolatey:

choco install unzip ripgrep fzf -y

  1. Navigate to the folder containing your opencode.exe. Double-click and Opencode should run.

xmintec avatar Jul 03 '25 15:07 xmintec

here is how it works for me

  1. Install Chocolatey Open PowerShell as administrator. Run the following command to relax the execution policy so the installation script can run:

Set-ExecutionPolicy Bypass -Scope Process -Force

Now run the official Chocolatey installation command:

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

  1. Install the missing tools with Chocolatey:

choco install unzip ripgrep fzf -y

  1. Navigate to the folder containing your opencode.exe. Double-click and Opencode should run.

Ideally though I think it would be best if this was bundled into the exe but if not possible then just document this

ikifar2012 avatar Jul 03 '25 17:07 ikifar2012

I have done this:

choco install unzip ripgrep fzf -y

I updated to the latest version v0.1.189

I still get the "no text" probem , issue #460

davidanew avatar Jul 04 '25 06:07 davidanew

I have done this:

choco install unzip ripgrep fzf -y

I updated to the latest version v0.1.189

I still get the "no text" probem , issue #460

You're right, you can't enter text. Unfortunately, I didn't test it any further than I left the welcome text from Opencode, which was fine for me because I had other things to do. It's the dependency on Bun that's a problem. I've now solved it for myself with Docker, but it's a bit of a hassle. Sooner or later, I'll install it on my Mac; it should work better there.

xmintec avatar Jul 04 '25 08:07 xmintec

For the "bun" problem:

● Here's the problematic macro import on line 5:

import { data } from "./models-macro" with { type: "macro" }

This is a Bun-specific macro import that executes the data() function at compile time to fetch model information from https://models.dev/api.json. The macro system is causing the crash on Windows.

To temporarily fix this, you can comment out that line:

// import { data } from "./models-macro" with { type: "macro" }

The macro is used to embed AI model data at build time, but the application should still work without it (though some model information might not be available).

This worked for me to get the opencode gui up. It still has the "no text" problem, but at least I can starting investigating it

davidanew avatar Jul 04 '25 09:07 davidanew

Setting "Use the legacy input encoding" in Poweshell settings -> Terminal emulation fixes the text problems

davidanew avatar Jul 04 '25 10:07 davidanew

I had a git hash related error when doing /init . This fixed it:

Update(packages/opencode/src/snapshot/index.ts) ⎿  Updated packages/opencode/src/snapshot/index.ts with 20 additions and 2 removals 46 log.info("commit") 47 48 // Extract commit hash from output like "[main abc1234] snapshot" 49 - const match = result.stdout.toString().match(/[.+ ([a-f0-9]+)]/) 50 - if (!match) throw new Error("Failed to extract commit hash") 49 + const output = result.stdout.toString() 50 + log.info("git commit output", { output, stderr: result.stderr.toString() }) 51 + 52 + const match = output.match(/[.+ ([a-f0-9]+)]/) 53 + if (!match) { 54 + // Fallback: get commit hash with git rev-parse 55 + try { 56 + const hashResult = await $git --git-dir ${git} rev-parse HEAD 57 + .quiet() 58 + .cwd(app.path.cwd) 59 + .nothrow() 60 + const hash = hashResult.stdout.toString().trim() 61 + if (hash && hash.length >= 7) { 62 + return hash.substring(0, 7) 63 + } 64 + } catch (e) { 65 + log.error("Failed to get commit hash with rev-parse", { error: e }) 66 + } 67 + throw new Error(Failed to extract commit hash from: ${output}) 68 + } 69 return match[1]

davidanew avatar Jul 04 '25 11:07 davidanew

"No text" issues might be related to num lock (see https://github.com/charmbracelet/x/issues/485). Can you try turning off num lock?

strager avatar Jul 05 '25 02:07 strager

See also #143

strager avatar Jul 05 '25 04:07 strager

#404 This issue still remain with the lastest patch

QDaed avatar Jul 05 '25 23:07 QDaed

@thdxr after starting the exe from the latest release i get this log (Win10).

INFO  2025-07-09T07:16:21 +63ms service=default version=0.2.13 args= opencode
INFO  2025-07-09T07:16:21 +8ms service=app cwd=C:\Users\******\opencode-windows-x64(1) creating
INFO  2025-07-09T07:16:21 +0ms service=app git
INFO  2025-07-09T07:16:21 +7ms service=bus type=storage.write subscribing
INFO  2025-07-09T07:16:21 +0ms service=app name=bus registering service
INFO  2025-07-09T07:16:21 +0ms service=format init
INFO  2025-07-09T07:16:21 +0ms service=bus type=file.edited subscribing
INFO  2025-07-09T07:16:21 +0ms service=config.hooks init
INFO  2025-07-09T07:16:21 +0ms service=bus type=file.edited subscribing
INFO  2025-07-09T07:16:21 +0ms service=bus type=session.idle subscribing
INFO  2025-07-09T07:16:21 +0ms service=app name=lsp registering service
INFO  2025-07-09T07:16:21 +0ms service=lsp initializing
INFO  2025-07-09T07:16:21 +4ms service=app name=file.watcher registering service
INFO  2025-07-09T07:16:21 +0ms service=app name=provider registering service
INFO  2025-07-09T07:16:21 +1ms service=app name=config registering service
INFO  2025-07-09T07:16:21 +4ms service=config loaded
INFO  2025-07-09T07:16:21 +2ms service=models.dev refreshing
INFO  2025-07-09T07:16:21 +0ms service=provider init
INFO  2025-07-09T07:16:21 +4ms service=app name=lsp shutdown
ERROR 2025-07-09T07:16:22 +885ms service=default name=Error message=Executable not found in $PATH: "unzip" fatal
ERROR 2025-07-09T07:16:22 +1ms service=default e=Executable not found in $PATH: "unzip" rejection

Did i miss any dependency installation process?

wienans avatar Jul 09 '25 07:07 wienans

i dont really know when will windows have a fix,it haven't usable since the first release with a lot of render bug, i love opencode as because it is good while i was using wsl2 but want to use it on windows to sync with my workflow since claude code not supported .

QDaed avatar Jul 12 '25 04:07 QDaed

i dont really know when will windows have a fix,it haven't usable since the first release with a lot of render bug, i love opencode as because it is good while i was using wsl2 but want to use it on windows to sync with my workflow since claude code not supported .

https://www.reddit.com/r/ClaudeAI/comments/1lxlezn/they_just_casually_dropped_support_for_windows/

(Dropped means added in gen z speak apparently)

davidanew avatar Jul 12 '25 06:07 davidanew

Found this thread for Windows testers

Few problems I got (Windows Terminal via PowerShell):

  • Scrolling up shows distorted views

  • Multi-line paste is sending each line right away instead of letting me paste it as a block of text

See attached image to see how the issues look like

Image

raymelon avatar Jul 12 '25 11:07 raymelon

for everybody having issues with opencode on Windows, setting what @davidanew suggested related to legacy input encoding will solve the 'no text' issue. However, the scrolling will still be distorted. I solved it by opening opencode in WezTerm...so yeah, works for me that way

ArmDaniel avatar Jul 13 '25 20:07 ArmDaniel

is this because we are using go tui? or why is this happening?

bramburn avatar Jul 14 '25 14:07 bramburn

What Claude Code team did was to run their commands using the MSYS2 Bash shell included in Git for Windows. That may be an easier start for opencode.

CarlosGtrz avatar Jul 14 '25 16:07 CarlosGtrz

Looking forward to OpenCode on Windows 🙏🏻

ikx94 avatar Jul 15 '25 05:07 ikx94

I'm working on a new fork for windows only. Rebuilding it with proper installation files rather than bun build.

bramburn avatar Jul 15 '25 06:07 bramburn

atm i'm using bash on windows , seems it is working now

QDaed avatar Jul 15 '25 11:07 QDaed

@thdxr since v0.3.9 the windows.zip file is detected as virus by windows defender v0.3.8 is working fine

wienans avatar Jul 15 '25 17:07 wienans

How are any of you even installing it? The site says to use the binary from the releases, but I go to the latest release and there simply isn't anything downloadable for windows

oenic avatar Jul 15 '25 20:07 oenic

How are any of you even installing it? The site says to use the binary from the releases, but I go to the latest release and there simply isn't anything downloadable for windows

Something happened with the latest release, but one previous has windows binary. https://github.com/sst/opencode/releases/tag/v0.3.10

illgitthat avatar Jul 16 '25 00:07 illgitthat

@ -Commands aren't really working. As soon as you type anything after @ you only get no matches found. /init isn't looking into subfolders

phob avatar Jul 16 '25 04:07 phob

For me now the boot up of opencode on windows works. But out of what ever reason, i can not type anything in the message box. All Shortcuts work but the messagebox doesn't

wienans avatar Jul 16 '25 12:07 wienans

The opencode fails to open the relative path ~

 lepa on  C:/
# opencode ~/opencode-playground
Error: Failed to change directory to C:\~\opencode-playground

this wotks -

opencode $env:USERPROFILE/opencode-playground

leporel avatar Jul 17 '25 00:07 leporel

where is ~/.local/share/opencode/ folder located in windows? I cant find it

TrueHOOHA avatar Jul 18 '25 03:07 TrueHOOHA

I've made a Chocolatey package for opencode that I'm happy to add to the chocolatey community packages. I noticed that the latest release (v0.3.19) doesn't have a windows executable at all. Is there a reason for that?

itsrainingmani avatar Jul 18 '25 04:07 itsrainingmani

it seems call tool but not executing on windows (using ollama)

I tried making powershell.exe as a soft link to bash.exe, but it didn't help, however the model wanted to execute the command in the WSL shell and somehow it worked.

But this is not the behavior I expect, why is Bun executing commands in WSL while opencode started in powershell

Image
{
  "id": "prt_81fbde98c001Dxxxx0iQ3orch9",
  "messageID": "msg_81fbd0ef40019381PHc5z8LvmD",
  "sessionID": "ses_7e042f5c3ffed2DGFCMg1HDSeR",
  "type": "tool",
  "tool": "bash",
  "callID": "call_qn93k91z",
  "state": {
    "status": "completed",
    "input": {
      "command": "ip -4 addr show",
      "description": "Gets IPv4 address in WSL environment"
    },
    "output": "<stdout>\n1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\n    inet 127.0.0.1/8 scope host lo\n       valid_lft forever preferred_lft forever\n    inet 10.255.255.254/32 brd 10.255.255.254 scope global lo\n       valid_lft forever preferred_lft forever\n2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000\n    inet 172.24.110.38/20 brd 172.24.111.255 scope global eth0\n       valid_lft forever preferred_lft forever\n\n</stdout>\n<stderr>\n\n</stderr>",
    "metadata": {
      "stderr": "",
      "stdout": "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\n    inet 127.0.0.1/8 scope host lo\n       valid_lft forever preferred_lft forever\n    inet 10.255.255.254/32 brd 10.255.255.254 scope global lo\n       valid_lft forever preferred_lft forever\n2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000\n    inet 172.24.110.38/20 brd 172.24.111.255 scope global eth0\n       valid_lft forever preferred_lft forever\n",
      "exit": 0,
      "description": "Gets IPv4 address in WSL environment"
    },
    "title": "ip -4 addr show",
    "time": {
      "start": 1752879196557,
      "end": 1752879196632
    }
  }
}

PS: I tested this code and it works, maybe this will be implemented?

    const proc = Bun.spawn({
      cmd: process.platform === "win32" 
      ? ["powershell.exe", "-Command", params.command]
      : ["bash", "-c", params.command],

https://github.com/sst/opencode/pull/1189

I made a PR with a fix for the bash tool call on Windows. I compiled a binary locally and am using it myself - now commands run natively in the Windows environment without relying on WSL.

leporel avatar Jul 18 '25 23:07 leporel