Files
magpie/docs
yetone f9a88c4fbe wsl: a distro's Pi from fnm, mise or an npmrc prefix is found, past a Windows one on PATH
千里不再 on Discord: Pi installed in WSL wasn't detected. The WSL probe
runs `sh -lc`, which reads ~/.profile but not ~/.bashrc, where fnm's
installer puts its PATH, so `command -v pi` missed it and wslbin had no
fnm folder. A Pi not run yet has no ~/.pi either, so nothing found it
(and for fnm users who had run it, its version was lost). Also, WSL
appends Windows' PATH, so a Pi npm installed on Windows answered
`command -v pi` with a /mnt/c path; that stopped the `|| wslbin`
fallback and parseProbe then dropped it as a Windows command (#406), so
the distro's own Pi was hidden.

Now wslcmd takes `command -v` only when it isn't on a Windows drive
(/mnt/X or any drive /proc/mounts lists), else walks PATH past Windows
drives, else wslbin. wslbin gains the folders proc.UserBinDirs has here:
fnm (aliases/default, then the highest version; FNM_DIR,
~/.local/share/fnm, ~/.fnm), mise's installs (highest), ~/.npmrc's
prefix, ~/.npm/bin, cargo, deno, Homebrew. Every WSL kind goes through
it, not only Pi.

Run:
- mote: GOOS=windows/linux/darwin go vet ./internal/agent; go test
  -run "TestWSL|TestOmo|TestPi" ./internal/agent ok. gofmt -l clean.
- wsl-run (magpie-desktop, Ubuntu 24.04): same tests ok.
- Real WSL: in magpie-desktop, a scratch HOME with the real fnm
  installer, `fnm install 22`, `npm i -g @mariozechner/pi-coding-agent`
  (pi 0.73.1), never run. Old probe: no bin:pi. New probe:
  `bin:pi .../fnm/aliases/default/bin/pi`, `ver:pi 0.73.1`, pi@wsl
  listed; a fnm codex was found past a /mnt/c one. Real home still finds
  codex, pi and claude (3.9s). Through proc.CommandContext on Windows
  (win-run) with Detect agents in WSL on, the probe runs (#4872 gates
  only when it is off).

Broken by hand: origin/main's wsl.go with the new tests: all four
subtests of TestWSLProbeFindsNodeManagersBins and
TestWSLProbeLooksPastWindowsCommand red.

Not tried: the reporter's own install (method unknown; fnm with a
never-run Pi is the case reproduced). Asking bash -i for ~/.bashrc's
PATH was tried and dropped: under timeout(1) an interactive bash stops
itself (state T) on WSL and outlived its timeout.

Reported-by: 千里不再 (Discord)
2026-11-06 23:47:29 +08:00
..