Commit Graph
2 Commits
Author SHA1 Message Date
yetone 9bad11449b proc, update: an agent installed in a folder only fish's config adds is found when the terminal opens fish but the login shell is zsh or bash (John on Discord)
John on Discord: 二进制文件没有从用户环境变量找到,我终端环境使用的fish. The desktop
app gets launchd's PATH and asks the login shell ($SHELL) for its own.
fish isn't a POSIX shell, so many keep zsh or bash as the login shell and
have the terminal open fish (its profile setting, or exec fish from
.zshrc). magpie then asked only zsh, and a claude or codex in a folder
config.fish adds (fish_add_path, set -gx PATH) wasn't seen.

The suspected cause, fish joining "$PATH" with spaces, isn't it: PATH is a
path variable in fish and is joined with ':' in double quotes. Checked with
real fish 4.9.3 (macOS), 3.6 and 4.0.2 (Debian, Docker) under -ilc with
the probe's printf and \0: PATH whole, the variables in place. With
SHELL=fish the old code already found the agent.

- shellEnv asks fish and nushell too, in parallel with the login shell,
  when they are installed and their config folder exists (each makes it
  on its first run) and they aren't the login shell. Their PATH folders
  come after the login shell's; a variable of agentenv.Vars the login
  shell leaves empty is taken from them.
- proc.FindShell finds a shell in the system's, Homebrew's, MacPorts',
  Nix's, ~/.local/bin and cargo's folders, then /etc/shells, then PATH.
  Settings > Command line (update.installedShells) uses it too, so a fish
  from MacPorts or Nix is listed there as well.
- The shellProbe comment now says why fish's "$PATH" is right.

Tests: TestShellEnvAsksFishBesideLoginShell (a fake fish answering with
the bytes real fish 4.9.3 printed) and TestShellEnvRealFish (real fish,
skipped where it isn't installed) fail on the old shellEnv:
  PATH = "/from/zsh:/usr/bin:/bin", want the login shell's first and
  fish's folder after
  PATH = "/usr/bin:/bin", want fish's ".../fish bin" in it
TestShellEnvLeavesUnusedFish and TestShellEnvFishLogin cover fish with no
config and fish as the login shell.

Run: internal/proc shell tests on macOS with the downloaded fish 4.9.3 and
on Linux (golang:1.26.8 + Debian fish 4.0.2) all pass; go test ./...
under a temp HOME: all pass except gateway (10m timeout under load; the
failing TestClaudeUnloadableSessionStartsAnew passes alone) and gui
TestOTelPreferencesAPI (TempDir cleanup race, passes alone -count=3),
neither touching this code; gofmt -l clean; go vet and GOOS=linux,
GOOS=windows go vet on internal/proc and internal/update clean.
Real use: a sandbox magpie (go build -tags dev, own HOME, ports
3486/3487, launchd-like PATH=/usr/bin:/bin:/usr/sbin:/sbin, SHELL=/bin/zsh
with no .zshrc, fish at ~/.local/bin/fish, a fake claude only in a folder
config.fish adds with fish_add_path): the old build reports no claude in
/api/agents/cli and /api/state; this one finds it (version 2.1.99 of the
fake). With SHELL=fish both builds find it.
2026-10-10 21:42:00 +08:00
yetone d6daa40ce3 update, gui: Settings › About › Command line says what magpie runs in a new terminal and adds it (PAMI on Discord) — the app downloaded from the site, and every Windows one, left terminals without the magpie command, and nothing in the GUI said whether it was there. A Command line row now asks each shell installed (zsh, bash, fish and the login shell; PowerShell and cmd on Windows) for its PATH and says, with a dot each, whether its magpie runs this app, another copy (with that copy's version, read from its .app's Info.plist or Homebrew Cellar folder, never by running it), or none. Add to PATH links this app's program (Homebrew's opt link, the AppImage) into the folder on the default shell's PATH whose magpie runs first, else ~/.local/bin or the like when on PATH, replacing another copy there as install.sh's ln -sf does; on Windows it puts the app's folder first in HKCU\Environment Path and broadcasts WM_SETTINGCHANGE. A shell whose PATH lacks that folder gets its own button naming its profile (~/.zshrc, ~/.bash_profile on the Mac or ~/.bashrc, fish's config.fish), which links into ~/.local/bin and adds that folder with one marked line, once; no profile is written otherwise. A translocated or disk-image app is told to move first and gets no button. It says new terminals take the change (on Windows: new PowerShell/cmd windows, restart Windows Terminal). GET/POST /api/cli; en/zh/ja/de. TestCLIOnPath (temp HOME, stubbed shells: link, fish profile once, a shadowing copy replaced, no folder → zsh's profile kept and appended, an unknown shell refused, plist version, translocated refused) and TestPathFirst are new; cli-path.test.cjs (WebKit, en and zh: per-shell dots, Add posts {} and turns green, fish's button posts fish alone, Windows lists PowerShell and cmd, translocated gets no button, no scroll, no select, no left border, translations) fails without the change; cli-behind and update-auto pass. Not tried on a real Windows machine. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass (TestOTelWholeWaterfallFallback and TestDevinSignedInOnlyInMagpie failed once each under load and pass alone). 2026-10-05 17:49:20 +08:00