Skip to content

fix(pi): find node on PATH when launching from Finder - #7

Merged
bytesbay merged 2 commits into
bytesbay:mainfrom
tsingwong:fix/pi-gui-node-path
Nov 21, 2026
Merged

bytesbay merged 2 commits into
bytesbay:mainfrom
tsingwong:fix/pi-gui-node-path

Conversation

@tsingwong

Copy link
Copy Markdown
Contributor

Why

Opening the app from Finder failed with env: node: No such file or directory even when pi --version worked in a terminal. Managed pi is a #!/usr/bin/env node script; GUI launches do not inherit mise/nvm/fnm PATH entries, and pi-node may be absent.

What changed

path_with_executable_dir now also prepends the directory of node found the same way as pi (PATH, then login shell), so child pi processes get a usable Node.

Scope

src/pi.rs only. Callers (check_installation, spawn_pi, updates, plugins) pick up the richer PATH with no API change.

Tradeoffs

Rejected installing or requiring pi-node. Login-shell lookup for node matches the existing pi discovery path and covers mise/nvm/fnm.

Blast Radius

First launch / version check may spend a login-shell lookup for node when it is not on the inherited PATH. Same cost class as discovering pi.

Verification

  • Fail: GUI-like PATH without node dir → env: node: No such file or directory
  • Pass: same with node dir prepended → 1.5.2
  • cargo test pi:: → 3 passed

Made with Cursor

@tsingwong
tsingwong force-pushed the fix/pi-gui-node-path branch from fccb010 to f7b9c7c Compare November 19, 2026 10:14
Spawning pi no longer asks the login shell on the UI thread: the check
remembers where node is and spawns only read it. A node next to pi skips
the lookup. The directory goes after the inherited PATH so it cannot
shadow other tools.
@bytesbay

Copy link
Copy Markdown
Owner

Thanks for the PR and for the clear write-up. The bug is real. pi's installer only puts its own pi-node on PATH, so with your own node from mise, nvm or fnm a Finder launch has no node at all.

I pushed a commit on top of yours (12557e5) that changes three things:

  • path_with_executable_dir runs on the main thread each time a chat or a plugin starts. With a Finder PATH every call started $SHELL -ilc "command -v node", about 0.75 s on my machine. Now check_installation finds node in the background and spawning pi only reads the result.
  • If node sits next to pi (the usual nvm setup), the lookup is skipped. That case already worked and should not pay for a shell start.
  • The node directory goes after the inherited PATH. In front of it, it could change which python or git the agent's commands get, for example when node is in /usr/bin and pyenv shims come earlier.

I also replaced the test. The old one passed without the fix whenever node was already on PATH, so the new ones check the PATH order directly.

Tested with a pi that has no node beside it and PATH=/usr/bin:/bin:/usr/sbin:/sbin: env: node: No such file or directory before, 1.5.2 after.

I'll squash-merge this and ship it in 0.2.9.

@bytesbay
bytesbay merged commit d066958 into bytesbay:main Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants