Skip to content

Detect pkg-compiled binaries correctly in install-source#42

Merged
yorkeccak merged 1 commit into
mainfrom
fix/pkg-binary-detection
Apr 17, 2026
Merged

Detect pkg-compiled binaries correctly in install-source#42
yorkeccak merged 1 commit into
mainfrom
fix/pkg-binary-detection

Conversation

@yorkeccak
Copy link
Copy Markdown
Contributor

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

  • `pnpm typecheck`, `pnpm build`
  • `pnpm test` - 37/37 (4 new install-source tests)
  • After merge: tag v1.0.8, verify a freshly-upgraded Homebrew `valyu` correctly reports `Install source: Homebrew`

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.
@yorkeccak yorkeccak merged commit a03de57 into main Apr 17, 2026
1 check passed
@yorkeccak yorkeccak deleted the fix/pkg-binary-detection branch April 17, 2026 13:43
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.

1 participant