fix: resolve pi binary from node_modules instead of bare PATH lookup#9
Open
minzique wants to merge 1 commit into
Open
fix: resolve pi binary from node_modules instead of bare PATH lookup#9minzique wants to merge 1 commit into
minzique wants to merge 1 commit into
Conversation
When ypi is installed globally via bun (or pnpm), transitive dependency binaries from @mariozechner/pi-coding-agent are NOT symlinked to the global bin directory. Both `ypi` and `rlm_query` call bare `pi` via exec/command, which either fails with 'pi: not found' or — worse — picks up the wrong `pi` npm package (a math pi-number calculator that squats the name). This was the exact failure path in practice: 1. User installs ypi → `pi` binary not on PATH 2. User runs `bun install -g pi` to fix it → installs wrong package 3. Wrong `pi` crashes: 'Cannot find module ./pi' (blocked postinstall) Fix: resolve the pi binary by searching node_modules relative to the script location (handles both hoisted and nested layouts), then fall back to PATH. ypi exports YPI_PI_BIN so rlm_query inherits the resolved path. Both scripts now give a clear error message pointing to the correct package (@mariozechner/pi-coding-agent) if pi can't be found.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #8
When
ypiis installed globally via bun (or pnpm), thepibinary from@mariozechner/pi-coding-agentis not symlinked to the global bin directory. Bothypiandrlm_querycall barepiviaexec/command, which either:pi: not found, orpinpm package (a math calculator that name-squatspion npm)Changes
ypinode_modulesrelative toSCRIPT_DIR(handles both hoisted and nested layouts)YPI_PI_BINso child processes (rlm_query) inherit the resolved path@mariozechner/pi-coding-agentif pi can't be foundexec pi→exec "$PI_BIN"rlm_queryYPI_PI_BINenv var from parentpiinvocations to use"$PI_BIN"Search order
Testing
Verified resolution against actual bun global install layout:
No breaking changes — if
piis already on PATH (npm global install, standalone install, or manual PATH setup), the fallback still works.