fix(pm): Windows support — normalize OS and use sh for postinstall#2702
Conversation
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>
…ibility" This reverts commit a6d9dee.
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>
Summary of ChangesHello, 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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
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>
There was a problem hiding this comment.
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.
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>
Summary
Fix utoo on Windows by addressing two root causes:
normalize_osmissing win32/windows mapping — Rust'sstd::env::consts::OSreturns"windows"but npm packages use"win32"in theirosfield. Without normalization, platform-specific optional dependencies like@rolldown/binding-win32-x64-msvcare incorrectly skipped on Windows.postinstall uses bash which may not be in PATH on Windows — Change from
bashtosh(POSIX compatible). Git for Windows providessh.exein PATH. Also convert[[ ]]bash-only syntax to POSIX[ ]in all templates.Changes
crates/ruborist/src/model/compatibility.rs: Add"win32" | "windows" => "win32"tonormalize_osvendor/templates/*.template:#!/bin/bash→#!/bin/sh,[[ ]]→[ ]vendor/templates/utoo.package.json.template:bash ./postinstall.sh→sh ./postinstall.shvendor/scripts/npm-utoo.sh: placeholder shebangs#!/bin/bash→#!/bin/she2e/utoo-pm.sh,e2e/utoo-pm.ps1: Add optional deps test case (rolldown binding)Test plan
cargo test -p utoo-ruborist -- compatibilitypasses🤖 Generated with Claude Code