refactor(setup): unify binary placement via setup --install#217
Merged
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Cli
Other
Bug Fixes 🐛Upgrade
Documentation 📚
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
…ment Move binary placement, directory selection, and post-install steps from the bash install script into the TypeScript setup command via --install. This creates a single code path shared by fresh installs and upgrades: - Extract binary management helpers into src/lib/binary.ts (directory selection, download URLs, locking, replacement, cleanup) - Add --install flag to setup command that handles binary placement from a temp download location, then continues with PATH/completions/skills - Simplify install script to just download to temp + delegate to setup - Change upgrade to spawn the NEW binary with setup --install (curl) or setup (package managers) after downloading - Remove setInstallInfo from upgrade.ts (setup now owns this) - Fix cognitive complexity lint error in upgrade.ts by extracting resolveTargetVersion helper
9714494 to
4531bac
Compare
Contributor
Codecov Results 📊✅ Patch coverage is 80.94%. Project has 3947 uncovered lines. Files with missing lines (64)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 67.31% 67.47% +0.16%
==========================================
Files 98 99 +1
Lines 12002 12133 +131
Branches 0 0 —
==========================================
+ Hits 8079 8186 +107
- Misses 3923 3947 +24
- Partials 0 0 —Generated by Codecov Action |
Add tests for: - setup --install flag: binary placement, welcome message, quiet mode - upgrade command: --check mode branches, already-up-to-date, version validation, v-prefix stripping - binary.ts: fetchWithUpgradeError (AbortError, network errors, non-Error throws), replaceBinary (Unix atomic rename)
CodeQL flagged urlStr.includes('registry.npmjs.org') as an
incomplete URL substring sanitization (high severity). Use
URL parsing to check hostname exactly instead.
…de check - Fix lock self-deadlock: acquireLock now recognizes process.ppid so the child (setup --install) can take over the parent's (upgrade) lock instead of erroring with 'Another upgrade is already in progress' - Fix tempPath collision: installBinary skips unlink+copy when sourcePath already IS the .download file (upgrade spawn case) - Fix PATH separator: use path.delimiter instead of hardcoded ':' in both binary.ts and shell.ts for Windows compatibility - Fix silent failure: runSetupOnNewBinary now checks exit code and throws UpgradeError on non-zero exit - Update stale comment in downloadBinaryToTemp explaining the ppid handoff - Add tests for ppid lock takeover, tempPath collision, and lock lifecycle
62386d7 to
9e5d954
Compare
- upgrade: always use execPath instead of storedInfo?.path which could reference a stale binary from a different installation method - binary: use static mkdirSync import instead of redundant dynamic import
…cation During curl upgrades, the child setup process re-evaluates determineInstallDir() which could resolve to a different directory (e.g. ~/.local/bin appeared since the original install). This left a stale binary at the original location that could shadow the new one. Fix: pass SENTRY_INSTALL_DIR in the child's environment, set to the current binary's install directory, so determineInstallDir() stays pinned to the same location.
BYK
commented
Feb 9, 2026
- upgrade: forward setup child's stdout/stderr to terminal so users see progress (Binary, PATH, Completions, Agent skills) - binary: rename replaceBinary → replaceBinarySync with JSDoc explaining why synchronous is intentional (uninterruptible rename sequence) - binary: convert installBinary's mkdir, unlink, chmod to async variants (function is already async; sync was unnecessary for these ops) - test: update imports for replaceBinarySync rename
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
startsWith(dir) without a trailing separator could false-positive on directories sharing a prefix (e.g. ~/.local/binaries matching ~/.local/bin). Append path.sep to KNOWN_CURL_PATHS so the check requires a proper directory boundary.
3 tasks
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
installscript intosentry cli setup --install, creating a single TypeScript code path shared by fresh installs and upgradessrc/lib/binary.ts(install dir resolution, download URLs, locking, atomic replacement)installscript to download-to-temp + delegate tosetup --installsetup --install(curl) orsetup(package managers) after downloadingsetupthe single owner ofsetInstallInfo, removing it from upgradeChanges
src/lib/binary.tssrc/commands/cli/setup.ts--installflag,handleInstall(), welcome messagesrc/commands/cli/upgrade.tsresolveTargetVersionextractionsrc/lib/upgrade.tsexecuteUpgradereturns temp pathinstallsetup --installsrc/bin.tscleanupOldBinary()→startCleanupOldBinary()renametest/lib/binary.test.tstest/lib/upgrade.test.tsTest plan
bun run lint— cleanbun run typecheck— cleanbinary.test.ts,upgrade.test.ts,setup.test.tspass