Detect pkg-compiled binaries correctly in install-source#42
Merged
Conversation
The standalone binaries built via pkg (used by Homebrew, the curl installer, and the PowerShell installer) run inside a virtual filesystem snapshot. Under that snapshot, process.argv[1] resolves to a path like "/snapshot/valyu-cli/dist/cli.cjs" that does not exist on the host filesystem and carries no information about where the binary actually came from. Prior behaviour: the install-source detector read argv[1], matched the "/dist/cli.cjs" suffix, and mis-classified every Homebrew or standalone-binary install as a "Dev checkout". valyu upgrade would then suggest "git pull && pnpm install && pnpm build" to users who installed with brew. Fix: when process.execPath looks like a compiled `valyu` binary (basename `valyu` / `valyu.exe`, or a path inside a Homebrew cellar), use it as the install location. Node-script invocations (npm global, dev builds) still read argv[1] as before, because process.execPath there is just `node` itself. Tests cover: Homebrew-pkg binary with argv[1] pointing at a /snapshot/ path, a standalone ~/.local/bin/valyu binary, an npm global install, and an unknown fallback. Bump to 1.0.8.
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.
Summary
The standalone binaries we ship (Homebrew, curl installer, PowerShell installer) are built via `pkg` and run inside a virtual filesystem snapshot. Inside that snapshot, `process.argv[1]` resolves to a path like `/snapshot/valyu-cli/dist/cli.cjs` - a non-existent host path that carries no information about where the binary came from.
The install-source detector was reading `process.argv[1]`, matching the `/dist/cli.cjs` suffix, and mis-classifying every Homebrew or standalone install as a "Dev checkout". Users who ran `valyu upgrade` after installing with Homebrew saw:
```
Install source: Dev checkout
Run: git pull && pnpm install && pnpm build
```
Fix
When `process.execPath` looks like a compiled `valyu` binary (basename `valyu` / `valyu.exe`, or a path inside a Homebrew cellar), use that as the install location. Node-script invocations (npm global, dev builds) still read `process.argv[1]` as before, because `process.execPath` there is just `node` itself.
New unit tests lock the four scenarios: Homebrew-pkg binary with argv[1] pointing at a `/snapshot/` path, a standalone `~/.local/bin/valyu` binary, an npm global install, and an unknown fallback.
Version
1.0.7 → 1.0.8.
Test plan