Skip to content

Windows compatibility #1382

@cscnk52

Description

@cscnk52

Summary

At Windows, the rust Command::new() just will search in PATH executable file, this mean it only search suffix is .exe, but at Windows, there are still lots of file executle via cmd files, like npm.

files under nodejs directory

🪟 | apps\nodejs\current |  v25.3.0
❯ ls

    Directory: C:\Users\cscnk52\scoop\apps\nodejs\current

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
l-r--          2026/01/14    10:44                bin -> C:\Users\cscnk52\scoop\persist\nodejs\bin
l-r--          2026/01/14    10:44                cache -> C:\Users\cscnk52\scoop\persist\nodejs\cache
d----          2026/01/13    02:51                node_modules
-a---          2026/01/13    01:49          55840 CHANGELOG.md
-a---          2026/01/13    01:49           3094 install_tools.bat
-a---          2026/01/14    10:44             58 install.json
-a---          2026/01/13    01:49         145976 LICENSE
-a---          2026/01/14    10:39           1783 manifest.json
-a---          2026/01/13    02:51       91691008 node.exe
-a---          2024/11/07    23:33            702 nodevars.bat
-a---          2024/11/07    23:34           2073 npm
-a---          2024/11/07    23:34            538 npm.cmd
-a---          2025/09/24    18:00           1700 npm.ps1
-a---          2024/11/07    23:34           2073 npx
-a---          2024/11/07    23:34            538 npx.cmd
-a---          2025/09/24    18:00           1700 npx.ps1
-a---          2026/01/13    01:49          42620 README.md

MIME type of npm script

🪟 | apps\nodejs\current |  v25.3.0
❯ file .\npm
npm: Bourne-Again shell script, ASCII text executable

🪟 | apps\nodejs\current |  v25.3.0
❯ file .\npm.cmd
.\npm.cmd: ASCII text, with CRLF line terminators

🪟 | apps\nodejs\current |  v25.3.0
❯ file .\npm.ps1
.\npm.ps1: a pwsh script, ASCII text executable, with CRLF line terminators

This is a life long problem in Rust Command standard library, related to:

Note on Windows: For executable files with the .exe extension, it can be omitted when specifying the program for this Command. However, if the file has a different extension, a filename including the extension needs to be provided, otherwise the file won’t be found.

see these document, I'm think whether we can make a polyfill for windows command search, like if Command::new("npm") is failed, then fallback to Command::new("npm.cmd").

There is some code for reproduce(should failed under Windows):

#[tokio::main]
async fn main() {
    let std_out = std::process::Command::new("npm")
        .arg("-v")
        .output()
        .expect("not found process under standard library");

    let tokio = tokio::process::Command::new("npm")
        .arg("-v")
        .output()
        .await
        .expect("not found process under tokio");
}

This issue is related to:

Platform

Windows_NT 10.0 x86_64 MS/Windows (Windows 11)

Version

prek 0.2.29 (b7a7bec 2026-01-16)

.pre-commit-config.yaml

See simple-icons/simple-icons#14245

.pre-commit-config.yaml

repos:
  - repo: local
    hooks:
      - id: format-icon-data
        name: Format icon data
        entry: npm run format:icondata
        language: system
        pass_filenames: false
        files: ^data/simple-icons\.json$
      - id: prettier
        name: Prettier
        entry: npm run prettier -- --write
        language: system
        pass_filenames: false
      - id: xo
        name: XO
        entry: xo --fix
        language: system
        pass_filenames: false
        types: [javascript]
      - id: ourlint
        name: Our lint
        language: system
        entry: node scripts/lint/ourlint.js
        pass_filenames: false
        always_run: true
      - id: jsonlint
        name: JSON Lint
        entry: node scripts/lint/jsonlint.js
        pass_filenames: false
        language: system
        types: [json]
      - id: svglint
        name: SVG Lint
        entry: svglint --ci --config svglint.config.mjs --git-changed
        pass_filenames: false
        language: system
        types: [svg]
        files: ^icons/.*\.svg$
        verbose: true
        stages: [commit]
      - id: markdownlint
        name: Markdownlint
        entry: "markdownlint-cli2 '**/*.md' '#node_modules'"
        pass_filenames: false
        types: [markdown]
        language: system

Log file

prek run -a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions