Skip to content

fix: Setup can update the CLI on older Windows PowerShell#1133

Merged
hatayama merged 2 commits into
v3-betafrom
feature/hatayama/fix-cli-update-hash
May 15, 2026
Merged

fix: Setup can update the CLI on older Windows PowerShell#1133
hatayama merged 2 commits into
v3-betafrom
feature/hatayama/fix-cli-update-hash

Conversation

@hatayama
Copy link
Copy Markdown
Owner

@hatayama hatayama commented May 15, 2026

Summary

  • Setup can update the Windows CLI even when optional PowerShell archive cmdlets are unavailable.
  • The installer keeps checksum verification and zip extraction working through .NET APIs.

User Impact

  • Previously, clicking the CLI update button in Setup could fail with a Get-FileHash not found error before the native CLI was installed.
  • After this change, the update path avoids that missing cmdlet and proceeds through the normal checksum and install flow.

Changes

  • Replaced the Windows installer checksum step with a SHA-256 helper based on .NET cryptography APIs.
  • Replaced zip extraction with a .NET ZipFile helper so the installer does not depend on Expand-Archive.
  • Added release-filter coverage to keep the PowerShell installer free of those optional cmdlets.

Verification

  • bash scripts/test-install-release-filter.sh
  • powershell -NoProfile -ExecutionPolicy Bypass -Command '$script = Get-Content -Path "scripts\\install.ps1" -Raw; $null = [scriptblock]::Create($script)'
  • PowerShell SHA-256 helper smoke test
  • PowerShell zip extraction helper smoke test
  • pwsh -NoProfile -Command '$script = Get-Content -Path "scripts\\install.ps1" -Raw; $null = [scriptblock]::Create($script)'
  • git diff --check

Summary

This PR makes the Windows installer resilient on older Windows PowerShell by removing dependencies on optional PowerShell archive/hash cmdlets. The installer now uses .NET APIs for SHA-256 checksumming and ZIP extraction so the CLI update path works even when Get-FileHash or Expand-Archive are unavailable.

Changes

Windows PowerShell Installer (scripts/install.ps1)

  • Added Get-UloopSha256Hash: computes SHA-256 using System.Security.Cryptography.SHA256 (no Get-FileHash).
  • Added Expand-UloopArchive: extracts ZIP using System.IO.Compression.ZipFile (no Expand-Archive).
  • Installer logic unchanged for checksum verification and extraction behavior, but now relies on .NET APIs available across PowerShell versions.

Test Coverage (scripts/test-install-release-filter.sh)

  • Extended/refactored test harness to mock additional release assets (including Windows .zip) and to parameterize uname via MOCK_UNAME_OS/MOCK_UNAME_ARCH.
  • Added mocks for curl, tar, sha256sum, and unzip to simulate Windows ZIP asset download and extraction.
  • Added helper write_legacy_npm_uloop_shim and converted legacy npm test setup from symlinks to a shim approach.
  • Added tests:
    • test_git_bash_latest_installs_windows_zip_asset — verifies Git Bash selection of Windows .zip asset.
    • test_powershell_installer_avoids_optional_archive_cmdlets — asserts install.ps1 uses Get-UloopSha256Hash and Expand-UloopArchive and does not reference Get-FileHash or Expand-Archive.
  • Both tests integrated into the main test script.

CI Workflow (.github/workflows/build-and-test.yml)

  • New Windows job test-windows-installers on windows-latest:
    • Runs scripts/test-install-release-filter.sh in Git Bash.
    • Parses scripts/install.ps1 in Windows PowerShell to ensure it loads as a script block.

Documentation

  • README and README_ja: clarified CLI-only terminal install instructions to note macOS and Windows Git Bash cases.

Impact

  • Fixes failures where the Setup CLI update path could error with missing Get-FileHash/Expand-Archive on older Windows PowerShell (e.g., pre-modern PowerShell on Windows 7/early Windows 10).
  • Maintains checksum verification and extraction integrity by using .NET APIs that are broadly available in Windows PowerShell.

Verification / Tests run

  • scripts/test-install-release-filter.sh
  • PowerShell and pwsh smoke tests that parse and execute install.ps1 scriptblock
  • git diff --check

Review Change Stack

Unity launches the Setup Wizard installer through Windows PowerShell, where optional archive cmdlets may be unavailable. Compute SHA-256 hashes and extract zip assets with .NET helpers so CLI updates do not fail before installing the native binary.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b4dd00f8-d7ac-4f28-9483-7ec2bb1481a5

📥 Commits

Reviewing files that changed from the base of the PR and between 754bf03 and 0267a3f.

📒 Files selected for processing (4)
  • .github/workflows/build-and-test.yml
  • README.md
  • README_ja.md
  • scripts/test-install-release-filter.sh
✅ Files skipped from review due to trivial changes (1)
  • README.md

📝 Walkthrough

Walkthrough

Add Windows zip assets to mocked releases; parameterize mocked uname; extend curl/tar mocks and add unzip handling to create an executable uloop.exe; replace symlink legacy uloop setup with an executable shim and wrapper tool scripts; update POSIX tests; add Git Bash and PowerShell tests; add a windows-latest CI job.

Changes

Windows installer and test-harness updates

Layer / File(s) Summary
Windows CI job
.github/workflows/build-and-test.yml
Add test-windows-installers job on windows-latest that runs scripts/test-install-release-filter.sh under Git Bash and parses scripts/install.ps1 in PowerShell.
README OS note
README.md, README_ja.md
Add "On macOS or Windows Git Bash:" lead-in to the CLI-only terminal install instructions (EN/JP).
Mocked releases include Windows zip assets
scripts/test-install-release-filter.sh
Include Windows .zip asset entries for v3.0.0-beta.2 and v2.0.0 in the generated releases JSON.
uname and curl mocks parameterized
scripts/test-install-release-filter.sh
Mock uname uses MOCK_UNAME_OS/MOCK_UNAME_ARCH; extend curl mock to serve Windows zip and .sha256 URLs with prerelease gating via ULOOP_VERSION.
Archive extraction and unzip mocks
scripts/test-install-release-filter.sh
tar mock now chmods extracted uloop; new unzip mock creates uloop.exe and makes it executable.
Legacy npm shim and tool wrappers
scripts/test-install-release-filter.sh
Add write_legacy_npm_uloop_shim to produce an executable legacy uloop shim; make mock binaries executable; change write_required_tool_links to produce wrapper scripts that exec tools.
POSIX tests updated to use shim
scripts/test-install-release-filter.sh
Update multiple POSIX tests to use the new legacy npm uloop shim helper instead of symlinks.
Git Bash and PowerShell tests added
scripts/test-install-release-filter.sh
Add test_git_bash_latest_installs_windows_zip_asset (verifies Windows zip selection and uloop.exe) and test_powershell_installer_avoids_optional_archive_cmdlets (asserts install.ps1 uses custom SHA256/ZipFile helpers and avoids Get-FileHash/Expand-Archive); register both in the test run list.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: Setup can update the CLI on older Windows PowerShell' directly addresses the core change: enabling CLI updates on older Windows PowerShell by using .NET APIs instead of optional cmdlets.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/hatayama/fix-cli-update-hash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Run the installer release-filter tests on a Windows runner with Git Bash so the Windows install.sh path stays exercised. Update the test harness to avoid Git Bash symlink-copy behavior and document the Git Bash install route.
@hatayama hatayama merged commit 6601ed3 into v3-beta May 15, 2026
5 checks passed
@hatayama hatayama deleted the feature/hatayama/fix-cli-update-hash branch May 15, 2026 23:03
@github-actions github-actions Bot mentioned this pull request May 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.

1 participant