[Bug]: OpenCode CLI unavailable after provider update attempt on Windows#27056

opened2d agobyCcodewarnab

### Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Reported sequence (not independently reproduced)

  1. On Windows 11, install OpenCode globally via npm: npm install -g @opencode/cli.
  2. Open T3 Code and connect OpenCode. A background opencode serve daemon is running.
  3. In T3 Code Settings → Providers, click "Update now" when an update is available (or trigger provider update).

Expected behavior

T3 Code updates the provider CLI package cleanly without corrupting the on-disk installation or unlinking active executables from PATH.

Actual behavior

The update fails and opencode completely vanishes from PATH.

powershell
1PS C:\Users\ASUS> opencode
2opencode : The term 'opencode' is not recognized as the name of a cmdlet, function, script file, or operable program.
3Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

And in T3 Code (~/.t3/caches/opencode.json):

json
1{
2 "displayName": "OpenCode",
3 "installed": false,
4 "status": "error",
5 "message": "OpenCode CLI (`opencode`) is not installed or not on PATH."
6}

Diagnosis (corrected; root cause not confirmed)

The symptoms above were observed during the incident. The earlier version of this report overstated the causal diagnosis.

A subsequent diagnostic command, npm list --global --depth 1, returned:

text
1ELSPROBLEMS
2invalid: @opencode/cli-windows-x64-baseline@

The retained npm log identifies this as an npm list failure, not an npm install failure. It supports an incomplete/invalid dependency tree but does not establish why the update failed or prove a Windows file lock.

Renamed npm shims and a placeholder at @opencode/cli/bin/opencode.exe were reported during the original investigation. These are consistent with an incomplete installation, but do not establish that postinstall never ran, that a running server caused the failure, or that npm was interrupted at a particular stage. The original installer error/exit status and a controlled reproduction are still needed.

“Not on PATH” here means the command could not be resolved; no change to the PATH environment variable itself has been demonstrated. Windows executable replacement restrictions are a possible contributing factor, not a confirmed cause. The earlier blanket claim about locking all in-use scripts was too broad.

Investigation / possible fix

Please investigate provider update behavior on Windows while an OpenCode server is active. If executable locking is confirmed, coordinate stopping/restarting the T3-owned server around the update or ask the user to close affected sessions. Avoid terminating unrelated OpenCode processes.

Current main's apps/server/src/provider/providerMaintenanceRunner.ts runs the installer with a five-minute timeout and then verifies provider state. That is useful context, but does not establish the cause on the reported nightly build.

Current status

After local recovery, the T3 provider cache reports OpenCode 2.2.1 as installed and ready. This report concerns the earlier failure; it has not yet been independently reproduced.

Impact

Blocks work completely

Version or commit

T3 Code Nightly 0.1.5-nightly.20261029.3867

Environment

  • OS: Windows 11 (Build 26300)
  • Node: v24.18.0 (nvm-windows)
  • npm: 11.16.0
  • OpenCode: @opencode/cli 2.1.4 -> 2.2.1

Recovery attempted locally (not a verified general workaround)

  1. The original recovery used the command below to stop OpenCode processes. It is broad and can terminate unrelated OpenCode sessions; prefer closing the affected application/server normally:
    powershell
    1Get-Process *opencode* -ErrorAction SilentlyContinue | Stop-Process -Force
  2. Manually run the package postinstall script and force-link the global package:
    powershell
    1node "<prefix>\node_modules\@opencode\cli\postinstall.mjs"
    2npm install -g --force @opencode/cli@latest