Skip to content

fix(pm): Windows support — normalize OS and use sh for postinstall#2702

Merged
xusd320 merged 10 commits into
nextfrom
fix/windows-glob
Mar 16, 2026
Merged

fix(pm): Windows support — normalize OS and use sh for postinstall#2702
xusd320 merged 10 commits into
nextfrom
fix/windows-glob

Conversation

@elrrrrrrr

Copy link
Copy Markdown
Contributor

Summary

Fix utoo on Windows by addressing two root causes:

  1. normalize_os missing win32/windows mapping — Rust's std::env::consts::OS returns "windows" but npm packages use "win32" in their os field. Without normalization, platform-specific optional dependencies like @rolldown/binding-win32-x64-msvc are incorrectly skipped on Windows.

  2. postinstall uses bash which may not be in PATH on Windows — Change from bash to sh (POSIX compatible). Git for Windows provides sh.exe in PATH. Also convert [[ ]] bash-only syntax to POSIX [ ] in all templates.

Changes

  • crates/ruborist/src/model/compatibility.rs: Add "win32" | "windows" => "win32" to normalize_os
  • vendor/templates/*.template: #!/bin/bash#!/bin/sh, [[ ]][ ]
  • vendor/templates/utoo.package.json.template: bash ./postinstall.shsh ./postinstall.sh
  • vendor/scripts/npm-utoo.sh: placeholder shebangs #!/bin/bash#!/bin/sh
  • e2e/utoo-pm.sh, e2e/utoo-pm.ps1: Add optional deps test case (rolldown binding)

Test plan

  • cargo test -p utoo-ruborist -- compatibility passes
  • E2E: rolldown binding installed on Windows/macOS/Linux

🤖 Generated with Claude Code

elrrrrrrr and others added 5 commits March 16, 2026 17:45
Rust's std::env::consts::OS returns "windows" but npm packages use
"win32" in their os field. Without normalization, packages like
@rolldown/binding-win32-x64-msvc are incorrectly skipped on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- postinstall.sh → postinstall.js: Node.js is always available, bash
  may not be on Windows without Git Bash
- Creates .exe copy of binary on Windows for cmd.exe execution
- Use #!/bin/sh instead of #!/bin/bash for placeholder binaries
- Update package.json template to use node ./postinstall.js

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verify that platform-specific optional dependencies like
@rolldown/binding-win32-x64-msvc are correctly installed.
This catches the normalize_os win32/windows bug.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bash may not be in PATH on Windows (only Git Bash's sh is guaranteed).
- Change postinstall from bash to sh in package.json
- Convert [[ ]] to POSIX [ ] in postinstall templates
- Change placeholder shebangs from #!/bin/bash to #!/bin/sh

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the utoo package manager's compatibility and reliability on Windows by addressing critical issues related to operating system identification and shell script execution. The changes ensure that platform-specific dependencies are correctly recognized and installed, and that postinstall scripts run successfully across various environments, leading to a more robust cross-platform experience.

Highlights

  • Windows OS Normalization: The normalize_os function in ruborist was updated to correctly map both "win32" and "windows" operating system strings to "win32", ensuring proper platform detection for optional dependencies on Windows.
  • Shell Script Compatibility: All relevant shell scripts and templates were modified to use #!/bin/sh instead of #!/bin/bash and to replace bash-specific [[ ]] conditional syntax with POSIX-compatible [ ]. This change improves compatibility, especially on Windows where sh.exe (provided by Git for Windows) is more reliably in the PATH than bash.exe.
  • End-to-End Test Coverage: New end-to-end test cases were added for both Windows (PowerShell) and Unix-like systems (Bash) to verify the correct installation and loading of platform-specific optional dependencies, specifically using the rolldown binding as an example.
Changelog
  • crates/ruborist/src/model/compatibility.rs
    • Added "win32" and "windows" to the normalize_os function to map to "win32".
  • e2e/utoo-pm.ps1
    • Added a new test case to verify the installation and loading of platform-specific optional dependencies (rolldown binding) on Windows.
  • e2e/utoo-pm.sh
    • Added a new test case to verify the installation and loading of platform-specific optional dependencies (rolldown binding) on Unix-like systems.
  • vendor/scripts/npm-utoo.sh
    • Changed shebangs in placeholder binaries from #!/bin/bash to #!/bin/sh.
  • vendor/templates/postinstall.sh.template
    • Changed shebang from #!/bin/bash to #!/bin/sh.
    • Replaced [[ ]] bash-specific syntax with POSIX [ ].
  • vendor/templates/postinstall.utoo.sh.template
    • Changed shebang from #!/bin/bash to #!/bin/sh.
    • Replaced [[ ]] bash-specific syntax with POSIX [ ].
  • vendor/templates/utoo.package.json.template
    • Updated the postinstall script command from bash ./postinstall.sh to sh ./postinstall.sh.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Simulates the setup-utoo / end-user flow:
1. Pack utoo binary into an npm tarball
2. npm install -g the tarball to a temp prefix
3. Verify the installed binary runs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request improves Windows support by normalizing the OS name in the Rust code and switching shell scripts from bash to the more portable sh. The changes are logical and well-supported by new end-to-end tests. I've suggested a couple of improvements to the new test scripts to make them more robust by dynamically detecting the architecture and failing explicitly on unsupported platforms instead of passing silently.

Comment thread e2e/utoo-pm.ps1 Outdated
Comment thread e2e/utoo-pm.sh Outdated
elrrrrrrr and others added 3 commits March 16, 2026 19:48
Verify the installed utoo is a real binary, not the placeholder script.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On Windows, npm install -g creates shim files at <prefix>/utoo.exe
that are text wrappers. Look for the actual binary inside
node_modules/utoo/bin/ instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Windows: detect arch dynamically for rolldown binding path
- Unix: fail explicitly when BINDING variable is empty

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@elrrrrrrr elrrrrrrr added the A-Pkg Manager Area: Package Manager label Mar 16, 2026

@killagu killagu 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.

LGTM

@xusd320 xusd320 merged commit 6f7aa84 into next Mar 16, 2026
23 checks passed
@xusd320 xusd320 deleted the fix/windows-glob branch March 16, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Pkg Manager Area: Package Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants