Skip to content

fix(pm): Windows runtime fixes — PATH, execute, global dir, cache#2706

Merged
elrrrrrrr merged 13 commits intonextfrom
fix/windows-runtime
Mar 20, 2026
Merged

fix(pm): Windows runtime fixes — PATH, execute, global dir, cache#2706
elrrrrrrr merged 13 commits intonextfrom
fix/windows-runtime

Conversation

@elrrrrrrr
Copy link
Contributor

@elrrrrrrr elrrrrrrr commented Mar 17, 2026

Summary

Follow-up to #2702. Fixes utoo runtime issues on Windows:

Changes

  1. PATH separator (platform_const.rs, script.rs)

    • Use ; instead of : on Windows — : conflicts with drive letters like D:
  2. execute_binary (execute.rs)

    • On Windows, prefer .cmd shim if exists, otherwise use sh to execute Unix shim scripts
    • Deduplicated cmd.args() per Gemini review
  3. Global package dir (global_bin.rs)

    • Use <prefix>/node_modules on Windows instead of <prefix>/lib/node_modules
  4. Platform constants (platform_const.rs)

    • Extract PATH_SEPARATOR and GLOBAL_NODE_MODULES constants to avoid scattered cfg!(windows)
  5. Cross-drive cache (user_config.rs)

    • Detect when cache dir (e.g. C:\.cache\nm) is on a different drive than project (e.g. D:\project)
    • Fall back to cache on project's drive to enable hardlinks

Verified

  • Windows e2e: egg install + build + 130 tests passed ✅
  • Windows e2e: ant-design install + build ✅
  • Windows e2e: ant-design-x install + build ✅
  • All CI checks: 20/20 SUCCESS ✅

🤖 Generated with Claude Code

elrrrrrrr and others added 3 commits March 17, 2026 19:58
On Windows, node_modules/.bin/ contains Unix shim scripts that
can't be executed directly. Prefer .cmd shim if available,
otherwise use sh to execute the Unix shim.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
build_path_env hardcoded ":" as PATH separator, but Windows uses ";".
This caused node_modules/.bin paths to not be found when executing
npm scripts via cmd.exe on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Windows npm global packages are in <prefix>/node_modules,
not <prefix>/lib/node_modules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
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 introduces several critical fixes to improve the package manager's compatibility and functionality on Windows. The changes address issues related to environment variable path handling, binary execution, and the location of global package installations, ensuring a more robust and native experience for Windows users. These adjustments are essential for the correct operation of the package manager across different operating systems.

Highlights

  • PATH separator: The PATH separator now correctly uses ; instead of : on Windows to avoid conflicts with drive letters.
  • execute_binary: The execute_binary function now prefers .cmd shims on Windows and falls back to sh for Unix shim scripts, resolving 'not a valid Win32 application' errors.
  • global package dir: The global package directory on Windows is now correctly set to <prefix>/node_modules instead of <prefix>/lib/node_modules.
Changelog
  • crates/pm/src/helper/global_bin.rs
    • Implemented platform-specific logic for get_global_package_dir to return <prefix>/node_modules on Windows and <prefix>/lib/node_modules on Unix.
  • crates/pm/src/service/execute.rs
    • Introduced conditional compilation for Windows to check for a .cmd shim alongside the binary path.
    • If a .cmd shim exists, it is executed directly.
    • If no .cmd shim is found, sh is used to execute the original binary path, assuming it's a Unix-style shim script.
    • Maintained existing Command::new(binary_path) behavior for non-Windows platforms.
  • crates/pm/src/service/script.rs
    • Changed the path_separator variable in build_path_env to be conditionally set to ; for Windows and : for other operating systems.
Activity
  • No human activity has occurred on this pull request since its creation.
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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 introduces several fixes for running on Windows. The changes correctly adjust the PATH separator, the global package directory path, and the binary execution logic for Windows environments. The code is functionally correct. The provided suggestion to refactor a section of the code for better readability and maintainability by reducing code duplication has been retained as it aligns with general best practices and does not contradict any specific rules.

@elrrrrrrr elrrrrrrr marked this pull request as draft March 17, 2026 12:07
elrrrrrrr and others added 2 commits March 18, 2026 11:55
Replace scattered cfg!(windows) with top-level imports:
- PATH_SEPARATOR: ";" on Windows, ":" on Unix
- GLOBAL_NODE_MODULES: "node_modules" on Windows, "lib/node_modules" on Unix

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Hardlinks cannot cross drive boundaries on Windows. When cache is on
C: but project is on D:, utoo falls back to copy (very slow).

Detect cross-drive and use a cache dir on the project's drive instead
(e.g. D:\.cache\nm).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@elrrrrrrr elrrrrrrr force-pushed the fix/windows-runtime branch from 2de6fdb to 9e0c88f Compare March 18, 2026 05:21
elrrrrrrr and others added 4 commits March 19, 2026 00:10
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use GLOBAL_NODE_MODULES constant instead of hardcoded 'lib/node_modules'.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@elrrrrrrr elrrrrrrr force-pushed the fix/windows-runtime branch from 1cd166f to 180e84f Compare March 19, 2026 06:13
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@elrrrrrrr elrrrrrrr changed the title fix(pm): Windows runtime fixes — PATH separator, execute binary, global dir fix(pm): Windows runtime fixes — PATH, execute, global dir, cache Mar 19, 2026
@elrrrrrrr elrrrrrrr force-pushed the fix/windows-runtime branch 2 times, most recently from 3a97f5d to e1ca87b Compare March 19, 2026 09:21
Use cwd.ancestors().last() to get drive root instead of manual
component extraction.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@elrrrrrrr elrrrrrrr force-pushed the fix/windows-runtime branch 6 times, most recently from 184bdc1 to 84c7685 Compare March 19, 2026 11:59
- Use top-level import for GLOBAL_NODE_MODULES in link.rs test
- Add ant-design-x install + build test case to both Windows and Unix e2e

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@elrrrrrrr elrrrrrrr force-pushed the fix/windows-runtime branch from 84c7685 to 581de21 Compare March 20, 2026 03:09
@elrrrrrrr elrrrrrrr requested review from Totoro-jam and killagu March 20, 2026 04:00
@elrrrrrrr elrrrrrrr added the A-Pkg Manager Area: Package Manager label Mar 20, 2026
@elrrrrrrr elrrrrrrr marked this pull request as ready for review March 20, 2026 04:03
@elrrrrrrr elrrrrrrr merged commit 5165555 into next Mar 20, 2026
24 checks passed
@elrrrrrrr elrrrrrrr deleted the fix/windows-runtime branch March 20, 2026 06:00
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.

2 participants