rtk cannot spawn .cmd/.sh wrapper commands on Windows (pnpm, npm, tsc)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 81k
- Forks
- 5.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 35
Description
Summary
When rtk wraps commands like pnpm, npm, npx, or tsc on Windows, they fail with:
Error: Failed to run pnpm
This is because rtk (Rust binary) spawns these as subprocesses, but on Windows they are not native executables — they are shell script wrappers or .cmd batch files that require a shell to interpret.
Root Cause
Windows Node.js toolchain installs wrapper scripts instead of real binaries:
| Command | Location | Actual file type |
|---|---|---|
pnpm |
Program Files/nodejs/ |
POSIX shell script + .CMD batch |
npm, npx |
Program Files/nodejs/ |
bash script + .cmd batch |
tsc |
AppData/Roaming/npm/ |
sh script + .cmd batch |
corepack |
Program Files/nodejs/ |
.cmd batch |
When Git Bash runs pnpm install directly, the shell interprets the wrapper script. But when rtk intercepts and tries to spawn pnpm as a subprocess (presumably via std::process::Command), it fails because:
- POSIX shell scripts need a shell interpreter
.cmdfiles needcmd.exe /cto execute
Current Workaround
In our PreToolUse hook (see #502), we added a passthrough list for known wrapper commands:
CMD_WRAPPER_RE="^(pnpm|pnpx|npm|npx|tsc|tsserver|corepack)([[:space:]]|$)"
if printf '%s' "$COMMAND" | sed 's/&&/\n/g; s/||/\n/g; s/;/\n/g' | sed 's/^[[:space:]]*//' | grep -qE "$CMD_WRAPPER_RE"; then
exit 0 # skip rtk for these commands
fi
This sacrifices rtk's token savings for these commands in exchange for execution reliability.
Suggested Fix
When spawning a command on Windows, rtk could:
- Check if the resolved path is a
.cmdfile → usecmd.exe /c <cmd> - Check if it's a shell script → use
sh -c <cmd>or the Git Bashbash.exe - Or simply always spawn via
cmd.exe /con Windows (similar to how Node.jschild_processhandles it withshell: true)
Related
- #502 — Windows hook support request (same environment)
Environment
- OS: Windows 11 Pro (10.0.26200)
- RTK: v0.27.2
- Node.js: installed via official installer (Program Files/nodejs/)
- pnpm: installed via corepack
- Shell: Git Bash (MINGW64)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Windows subprocess spawning path that uses std::process::Command, then reproduce the failure with pnpm, npm, npx, tsc, or corepack on Windows. Compare handling of .cmd files and shell scripts, and verify that the affected wrapper commands execute successfully without the passthrough workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, shell
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100