Skip to content

fix(core): extract zips with tar on Windows instead of Expand-Archive#36035

Closed
YayoRazo wants to merge 1 commit into
anomalyco:devfrom
YayoRazo:fix-windows-zip-tar
Closed

fix(core): extract zips with tar on Windows instead of Expand-Archive#36035
YayoRazo wants to merge 1 commit into
anomalyco:devfrom
YayoRazo:fix-windows-zip-tar

Conversation

@YayoRazo

@YayoRazo YayoRazo commented Jul 9, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #24291

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On Windows, zip extraction (the ripgrep download and LSP server installs) shells out to PowerShell's Expand-Archive. When opencode runs as the Bun-compiled binary, powershell.exe fails to autoload Microsoft.PowerShell.Archive ("the module could not be loaded"), which breaks the skill and glob tools.

The fix swaps both PowerShell call sites for Windows' built-in tar.exe. Why this works: Windows has shipped bsdtar since Windows 10 1803 and Bun requires 1809+, so tar is always present on any machine that can run opencode, and bsdtar reads zip archives natively — no PowerShell process, no module autoload, so the Bun environment issue can't be hit. This also matches the tar.gz extraction path already used on macOS/Linux.

  • packages/core/src/ripgrep/binary.ts: zip and tar.gz now share one tar invocation (-xf vs -xzf)
  • packages/opencode/src/util/archive.ts: same swap; adds an explicit mkdir for the destination (Expand-Archive created it implicitly, tar -C does not) and removes the single-quote interpolation that broke on paths containing '

How did you verify your code works?

  • On Windows 11: extracted a ripgrep-layout zip with nested dirs, spaces and apostrophes in file names via the exact tar -xf <zip> -C <dest> invocation; re-extracted over existing files to confirm overwrite parity with -Force; exit 0 and correct contents both times.
  • bun run typecheck passes in packages/core and packages/opencode; full pre-push turbo typecheck green (30/30).

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@YayoRazo

YayoRazo commented Jul 9, 2026

Copy link
Copy Markdown
Author

For context: this differs from the earlier attempt in #25396, which still spawned powershell.exe and used .NET ZipFile to dodge the module autoload. This PR removes PowerShell from the extraction path entirely — tar.exe is a plain native process with no module system, so the Bun env issue can't affect it regardless of its exact mechanism. It also drops a process spawn layer and matches the tar path already used on macOS/Linux.

PowerShell's Microsoft.PowerShell.Archive module fails to autoload when
powershell.exe is spawned from the Bun-compiled binary, breaking zip
extraction for the ripgrep download and LSP server installs on Windows.

Windows ships bsdtar as tar.exe since Windows 10 1803 (Bun requires
1809+), and it extracts zip archives natively, so both call sites now
use the same tar path that macOS/Linux already use for tar.gz. The
destination directory is created explicitly (Expand-Archive did it
implicitly), and the unescaped single-quote interpolation in
extractZip goes away with the PowerShell command string.

Fixes #24291
@YayoRazo YayoRazo changed the title fix: extract zips with tar on Windows instead of Expand-Archive fix(core): extract zips with tar on Windows instead of Expand-Archive Jul 9, 2026
@YayoRazo
YayoRazo force-pushed the fix-windows-zip-tar branch from ef4a637 to bf6dd83 Compare July 9, 2026 07:54
CreatorGhost added a commit to CreatorGhost/TheCode that referenced this pull request Jul 12, 2026
CreatorGhost added a commit to CreatorGhost/TheCode that referenced this pull request Jul 12, 2026
@YayoRazo YayoRazo closed this by deleting the head repository Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Expand-Archive module auto-load fails when spawned from opencode.exe (Bun)

1 participant