Skip to content

skill tool fails with EUNKNOWN: unknown error, uv_spawn when PowerShell is denied by policy (Windows) #52306

Closed as not planned

Description

@jrunic

Description

EUNKNOWN: unknown error, uv_spawn when loading any skill (including with --pure) on a Windows machine where PowerShell execution is denied by Group Policy / AppLocker. cmd.exe and direct file reads work fine — only skill loading fails.

Root cause (found in source)

  • packages/opencode/src/tool/skill.ts — the skill tool calls ripgrep.find({ cwd: dir, ... }) to list the skill's files every time a skill is loaded.
  • packages/core/src/ripgrep/binary.ts — RipgrepBinary.Service.filepath resolves the rg binary by: (1) checking which("rg.exe") on PATH, (2) checking a cached copy, (3) downloading ripgrep-<version>-<arch>-pc-windows-msvc.zip from GitHub and extracting it.
  • On Windows, the .zip extraction path is hardcoded to PowerShell, with no fallback:
if (config.extension === "zip") {
  const shell = (yield* Effect.sync(() => which("powershell.exe") ?? which("pwsh.exe"))) ?? "powershell.exe"
  const result = yield* run(shell, [
    "-NoProfile", "-NonInteractive", "-Command",
    `$global:ProgressPreference = 'SilentlyContinue'; Expand-Archive -LiteralPath '${archive}' -DestinationPath '${dir}' -Force`,
  ])
  ...
}

On a machine where PowerShell execution is denied by policy, which("powershell.exe") still resolves the binary (it's present on disk and on PATH — the policy denies execution, not presence), so the code proceeds to spawn it. Windows then rejects the CreateProcess call at the OS level (observed message: "This program is blocked by group policy"). That rejection surfaces as an unclassified/unknown error to libuv — hence EUNKNOWN: unknown error, uv_spawn instead of a more legible permission error.

Windows ships tar.exe natively (used for .tar.gz on other platforms in the same file), which can extract .zip archives too and is not subject to the PowerShell policy restriction. Using tar (or falling back to it when PowerShell isn't available/executable) instead of Expand-Archive for the Windows .zip case would avoid this failure mode entirely.

Reproduced

On a Windows 11 VM with an AppLocker policy that denies powershell.exe/pwsh.exe/powershell_ise.exe execution for a specific user (everything else allowed):

> where powershell.exe
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

> powershell.exe -NoProfile -NonInteractive -Command "Write-Host hello"
This program is blocked by a group policy. For more information, contact your system administrator.

opencode's .cache\opencode\bin\ directory on that account contained a downloaded-but-never-extracted ripgrep-15.1.0-aarch64-pc-windows-msvc.zip, re-downloaded on every session (extraction silently failing each time, never producing rg.exe).

Manually extracting the same zip with tar -xf ripgrep-....zip -C <dir> works without issue on the same account, confirming tar is not affected by the policy that blocks PowerShell.

Workaround

Place a working rg.exe somewhere already on PATH — RipgrepBinary.filepath checks which("rg.exe") first and skips the download/extract path entirely if found.

OpenCode version

Observed on 1.18.25 and reported independently on 1.18.33; the relevant code (packages/core/src/ripgrep/binary.ts) is unchanged between those versions (last touched 2026-06-30).

Operating System

Windows 11 (reproduced on ARM64; the extraction mechanism itself is architecture-independent — any Windows machine with PowerShell execution denied by policy should hit this)

Terminal

cmd.exe / non-interactive (scheduled task)

Activity

  1. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • #40623: Windows ripgrep ZIP extraction via PowerShell fails, causing grep/glob and skill failures.
    • #24489: Windows skill loading fails when the PowerShell archive module cannot load.
    • #23457: Skill loading fails during the same ripgrep ZIP extraction and Expand-Archive path.
    • #29957: Windows skill loading fails due to PowerShell 5.1 Expand-Archive behavior.
    • #24291: Expand-Archive fails when spawned internally by OpenCode, affecting skill-related tools.
  2. ggbdpq commented on Oct 1, 2026

    @ggbdpq

    Confirmed in source: on policy-restricted machines which("powershell.exe") still resolves the binary (policy denies execution, not presence), the Expand-Archive spawn gets rejected at CreateProcess, and it surfaces as the opaque EUNKNOWN uv_spawn.

    Windows ships a libarchive-based tar.exe in System32 (Win10 1803+) that extracts zip archives and is not subject to PowerShell execution policy, so I'll switch the zip branch to prefer it and keep Expand-Archive as the fallback for systems without tar.exe. Taking this one.

  3. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions