Skip to content

fix(cli): use PowerShell Expand-Archive for zip extraction on Windows - #21

Merged
olamide226 merged 1 commit into
RuachTech:mainfrom
SasanTazayoni:bugfix/cli-windows-tar-extraction
Feb 27, 2026
Merged

fix(cli): use PowerShell Expand-Archive for zip extraction on Windows#21
olamide226 merged 1 commit into
RuachTech:mainfrom
SasanTazayoni:bugfix/cli-windows-tar-extraction

Conversation

@SasanTazayoni

Copy link
Copy Markdown
Contributor

What

Replace tar -xf with PowerShell's Expand-Archive for zip extraction on Windows in the CLI postinstall script.

Why

Windows built-in tar.exe (BSD tar) misinterprets the drive letter in a -C path (e.g. -C "C:\...") as a network hostname, causing extraction to fail with:

tar: Cannot connect to C: resolve failed

The zip is downloaded successfully — only the extraction step breaks. This affects any Windows user installing @rep-protocol/cli via pnpm/npm.

Fix: detect process.platform === 'win32' (via the existing IS_WINDOWS constant) and use PowerShell's Expand-Archive on Windows. All other platforms continue to use tar as before.

Type

  • fix — Bug fix (patch)

Windows built-in tar.exe (BSD tar) misinterprets the drive letter in
a -C path (e.g. -C "C:\...") as a network hostname, causing extraction
to fail with "tar: Cannot connect to C: resolve failed". On Windows,
switch to PowerShell's Expand-Archive which handles Windows paths
correctly. Non-Windows platforms continue to use tar as before.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a Windows-specific bug in the CLI postinstall script where tar -xf with a -C path containing a drive letter fails because Windows' BSD tar misinterprets the drive letter as a network hostname. The fix detects Windows via the existing IS_WINDOWS constant and uses PowerShell's Expand-Archive cmdlet instead of tar for zip extraction on Windows systems.

Changes:

  • Replace tar -xf command with platform-specific extraction logic
  • Add Windows-specific PowerShell Expand-Archive command for zip files
  • Maintain backward compatibility with tar for non-Windows platforms

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/scripts/postinstall.js
Comment thread cli/scripts/postinstall.js
Comment thread cli/scripts/postinstall.js
@olamide226
olamide226 merged commit f8cd44c into RuachTech:main Feb 27, 2026
13 checks passed
@github-actions github-actions Bot mentioned this pull request Feb 27, 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.

3 participants