Skip to content

Commit e1b3c06

Browse files
committed
test: confirm pnpm global bin layout in #149 probe
Run 2 showed pnpm setup reports global bin = %PNPM_HOME%\bin (= %LOCALAPPDATA% \pnpm\bin), matching the #149 report, but the in-process global install didn't land a shim. Configure global-bin-dir explicitly and install a tiny package (cowsay) to reveal pnpm's real .cmd path/casing, then launch that absolute shim directly to confirm a hardcoded-path fix needs no cmd /C wrapper.
1 parent 00c7c14 commit e1b3c06

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

.github/workflows/win-opencode-probe.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,41 @@ jobs:
2525
run: cargo test win_cmd_shim_execution_probe -- --ignored --nocapture
2626

2727
# --- Real-world reproduction: a pnpm-global opencode, exactly like #149. ---
28-
- name: Install opencode via pnpm (reproduce #149 layout)
28+
- name: Confirm pnpm global .cmd shim layout (#149 mechanism 1)
2929
shell: pwsh
3030
continue-on-error: true
3131
run: |
3232
npm install -g pnpm
33-
# pnpm global installs need PNPM_HOME established first; `pnpm setup`
34-
# writes it to the user env. Apply it to this process so `add -g` lands.
35-
pnpm setup 2>&1 | Out-Host
36-
if (-not $env:PNPM_HOME) { $env:PNPM_HOME = "$env:LOCALAPPDATA\pnpm" }
37-
$env:PATH = "$env:PNPM_HOME;$env:PATH"
38-
pnpm add -g opencode-ai 2>&1 | Out-Host
39-
Write-Host "PNPM_HOME=$env:PNPM_HOME"
33+
# pnpm's global bin dir is %PNPM_HOME%\bin (= %LOCALAPPDATA%\pnpm\bin),
34+
# which is exactly the #149 layout. Configure + PATH it in-process so a
35+
# global install actually lands, then observe where the .cmd shim goes.
36+
$env:PNPM_HOME = "$env:LOCALAPPDATA\pnpm"
37+
$binDir = Join-Path $env:PNPM_HOME "bin"
38+
New-Item -ItemType Directory -Force -Path $binDir | Out-Null
39+
$env:PATH = "$binDir;$env:PNPM_HOME;$env:PATH"
40+
pnpm config set global-bin-dir "$binDir"
4041
Write-Host "pnpm bin -g => $(pnpm bin -g 2>$null)"
41-
Write-Host "--- opencode* under PNPM_HOME ---"
42-
$shims = Get-ChildItem -Recurse -Filter "opencode*" "$env:PNPM_HOME" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
43-
$shims | ForEach-Object { Write-Host $_ }
44-
Write-Host "--- where.exe opencode (PATH includes pnpm now) ---"
45-
where.exe opencode 2>&1 | Out-Host
46-
# Capture the real .cmd shim absolute path for the next step (each run
47-
# step is a fresh shell, so pass it via GITHUB_ENV rather than PATH).
48-
$cmdShim = $shims | Where-Object { $_ -like "*opencode.cmd" } | Select-Object -First 1
49-
if ($cmdShim) { "OPENCODE_SHIM=$cmdShim" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 }
42+
# A tiny package with a bin is enough to reveal pnpm's shim path/casing;
43+
# the heavy opencode-ai install is unnecessary to confirm the LOCATION.
44+
pnpm add -g cowsay 2>&1 | Out-Host
45+
Write-Host "--- *.cmd placed by pnpm ---"
46+
$cmds = Get-ChildItem -Recurse -Filter "*.cmd" "$env:PNPM_HOME" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
47+
$cmds | ForEach-Object { Write-Host $_ }
48+
# Pass one real pnpm-placed shim to the next step to launch directly.
49+
$shim = $cmds | Select-Object -First 1
50+
if ($shim) { "OPENCODE_SHIM=$shim" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 }
5051
51-
- name: Probe the real pnpm shim (direct vs cmd /C)
52+
- name: Probe the real pnpm shim (direct launch)
5253
shell: pwsh
5354
continue-on-error: true
5455
run: |
55-
# Use the absolute pnpm shim path captured above. A GUI launch of the
56-
# dashboard would NOT have pnpm on PATH (mechanism 1), so testing the
57-
# absolute path is the faithful question: given the path, does a direct
58-
# CreateProcessW launch (identical to Rust's Command) succeed?
56+
# A GUI launch of the dashboard would NOT have pnpm on PATH (mechanism
57+
# 1), so the faithful question is: given the absolute pnpm shim path,
58+
# does a direct CreateProcessW launch (identical to Rust's Command)
59+
# succeed? If yes, hardcoding the pnpm path in the candidate list fixes
60+
# #149 with no cmd /C wrapper needed.
5961
$shim = $env:OPENCODE_SHIM
60-
if (-not $shim) { Write-Host "pnpm opencode.cmd shim not found; skipping"; exit 0 }
62+
if (-not $shim) { Write-Host "no pnpm .cmd shim captured; skipping"; exit 0 }
6163
Write-Host "resolved shim: $shim"
6264
6365
function Try-Launch($file, $arguments) {

0 commit comments

Comments
 (0)