Skip to content

Commit 6b87c46

Browse files
authored
fix: Windows standalone mode — bypass broken npm shims (#217)
* fix: overwrite npm .cmd wrappers for @pnpm/exe on Windows npm creates .cmd wrappers that invoke bin entries through `node`, but @pnpm/exe bins are native executables, not JavaScript files. This causes pnpm commands to silently fail on Windows. * fix: copy pnpm.exe to .bin/ on Windows for standalone mode The .cmd wrapper approach didn't work because CMD doesn't properly wait for extensionless PE binaries. Instead, copy the actual .exe (and .cmd for pnpx) from @pnpm/exe into .bin/ so PATHEXT finds pnpm.exe directly, bypassing npm's broken node-wrapping shim. * fix: add @pnpm/exe dir to PATH on Windows instead of .bin shims On Windows, npm's .bin shims can't properly execute the extensionless native binaries from @pnpm/exe. Instead of trying to fix the shims, add the @pnpm/exe directory directly to PATH where pnpm.exe lives. * test: validate pnpm --version output in CI All version checks now capture output and assert it matches a semver pattern. Previously, a silently failing pnpm (exit 0, no output) would pass the tests. * debug: log pnpm --version output during setup * fix: remove duplicate addPath in setOutputs that shadowed pnpm.exe setOutputs called addPath(node_modules/.bin) AFTER installPnpm had already added the correct path (@pnpm/exe on Windows). Since GITHUB_PATH entries are prepended, .bin ended up first in PATH, causing PowerShell to find npm's broken shims instead of pnpm.exe. * fix: add PNPM_HOME/bin to PATH on all platforms * fix: address review feedback — PATH ordering and regex anchoring - Swap addPath order so pnpmHome (with pnpm.exe) is prepended last and has highest precedence over pnpmHome/bin. - Anchor version regex with $ and allow prerelease suffixes.
1 parent 994d756 commit 6b87c46

File tree

4 files changed

+166
-127
lines changed

4 files changed

+166
-127
lines changed

.github/workflows/test.yaml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ jobs:
3333
run: which pnpm; which pnpx
3434

3535
- name: 'Test: version'
36-
run: pnpm --version
36+
run: |
37+
actual="$(pnpm --version)"
38+
echo "pnpm version: ${actual}"
39+
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
40+
echo "ERROR: pnpm --version did not produce valid output"
41+
exit 1
42+
fi
43+
shell: bash
3744

3845
- name: 'Test: install in a fresh project'
3946
run: |
@@ -71,7 +78,14 @@ jobs:
7178
run: which pnpm && which pnpx
7279

7380
- name: 'Test: version'
74-
run: pnpm --version
81+
run: |
82+
actual="$(pnpm --version)"
83+
echo "pnpm version: ${actual}"
84+
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
85+
echo "ERROR: pnpm --version did not produce valid output"
86+
exit 1
87+
fi
88+
shell: bash
7589

7690
test_standalone:
7791
name: Test with standalone
@@ -98,7 +112,14 @@ jobs:
98112
run: which pnpm
99113

100114
- name: 'Test: version'
101-
run: pnpm --version
115+
run: |
116+
actual="$(pnpm --version)"
117+
echo "pnpm version: ${actual}"
118+
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
119+
echo "ERROR: pnpm --version did not produce valid output"
120+
exit 1
121+
fi
122+
shell: bash
102123

103124
- name: 'Test: install in a fresh project'
104125
run: |
@@ -196,4 +217,11 @@ jobs:
196217
run: which pnpm; which pnpx
197218

198219
- name: 'Test: version'
199-
run: pnpm --version
220+
run: |
221+
actual="$(pnpm --version)"
222+
echo "pnpm version: ${actual}"
223+
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
224+
echo "ERROR: pnpm --version did not produce valid output"
225+
exit 1
226+
fi
227+
shell: bash

0 commit comments

Comments
 (0)