mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-03 11:01:22 +08:00
f07edc7680
`grok update` discovers and installs releases by spawning `npm view` and `npm i -g`, even for xAI's native install — 0.2.112 moved the self-update path onto npm distribution, so the binary now needs node on PATH. Lifecycle scripts run under a non-login `bash -c` inheriting launchd's narrow PATH, where npm and node are invisible, so upgrading grok failed with a bare `Error: No such file or directory (os error 2)`. Inject the login shell's real PATH into run_tool_lifecycle_silently, closing the asymmetry between probing (`$SHELL -lic`, which reads .zshrc) and execution (non-login bash). Read it through `/usr/bin/env` rather than `echo $PATH`: fish stores PATH as a list and would emit space-separated segments, while env always prints the child's real environment. This also revives the install chain's bare `npm i -g` fallback, which could only ever exit 127 under the narrow PATH. Chain the official installer after native Grok's self-update. An npm fallback would share both of the primary's failure modes — no node, or a registry mirror missing the tarball — and fail alongside it; the installer is the only node-free path and lands in the same ~/.grok/bin. It also rewrites `[cli] installer` back to `internal`, healing users whom the install-time npm fallback had switched onto npm distribution.