Fix upgrade fails to find package.json #1030
Open
clarajohan wants to merge 1 commit into
Open
Conversation
- Added detectBunGlobalInstallRoot() helper that walks up from realpath(process.argv[1]) and returns the first ancestor with both package.json AND a
node_modules/ subdir.
- case 'bun': now calls it and passes the result as cwd to execFileSync('bun', ['update', 'gbrain'], ...).
- Switched from execSync to execFileSync (no shell needed, tighter surface).
- When detection fails, prints a paste-ready manual recovery line instead of the misleading "Upgrade failed" message.
Test (test/upgrade-bun-cwd.serial.test.ts, 5 cases): walks up correctly inside a faithful ~/.bun/install/global/ replica; returns null on missing
argv[1]; returns null on no install-root signal; rejects node_modules/gbrain/package.json as a false positive (the "first package.json wins" trap);
resolves through the symlinked-bin shape (~/.bun/bin/gbrain → real cli.ts). Marked .serial.test.ts because it mutates process.argv[1], which is
process-global. macOS /tmp → /private/tmp symlink handled by realpath'ing the workDir in beforeEach.
Author
|
Another fix 1032 addresses the same issue. If that fix is merged, close this one |
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.
Fixes Issue 1029
Test (test/upgrade-bun-cwd.serial.test.ts, 5 cases): walks up correctly inside a faithful
/.bun/install/global/ replica; returns null on missing/.bun/bin/gbrain → real cli.ts). Marked .serial.test.ts because it mutates process.argv[1], which isargv[1]; returns null on no install-root signal; rejects node_modules/gbrain/package.json as a false positive (the "first package.json wins" trap);
resolves through the symlinked-bin shape (
process-global. macOS /tmp → /private/tmp symlink handled by realpath'ing the workDir in beforeEach.
Fixes #1029