Skip to content

refactor(cli): make the install scripts readable top to bottom - #2404

Open
sentry-junior[bot] wants to merge 4 commits into
mainfrom
junior/readable-installers
Open

sentry-junior[bot] wants to merge 4 commits into
mainfrom
junior/readable-installers

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Restructures packages/cli/install and packages/cli/install.ps1 so that someone reading the installer before they pipe it to a shell can follow it. Today that means reading 700 lines of top-level code. Two behavior changes are listed below. Otherwise requests, messages, telemetry step tags, setup arguments, and exit codes stay the same.

Key Changes

  • One readable happy path. bash main() and PowerShell Invoke-Install come right after the header and list the install steps in order: parse args, detect the platform, resolve the release, download and verify, run sentry cli setup, then run sentry init if asked.
  • Named helpers per step, grouped under section banners. Each one has a short comment that says what it does and why.
  • Guard clauses instead of nesting. The stable download, the registry lookup, and the nightly GHCR flow now use early returns. Repeated failure handling moves into require_download and require_good_checksum, and the duplicated JSON awk one-liners move into json_field.
  • bash runs main "$@" on its last line, so a curl | bash download that gets cut off runs nothing.
  • State in one place. Installer state is declared once at the top, with a comment on each variable.
  • PowerShell: Repair-Download and Assert-Sha256 merge into Confirm-Download. Gzip expansion moves into Expand-Gzip. Download, setup, and init each get their own function.

Behavior change: no GitHub fallback for latest (both installers)

When Sentry's release registry is down, an unpinned install now stops with "Failed to fetch latest stable version from Sentry's release registry. Retry or install a specific version". It no longer pages through GitHub releases to find the newest stable cli@ tag. A pinned version (--version / SENTRY_VERSION) still downloads from its GitHub release. This removes the GitHub API client, its token and rate-limit handling, and the release-page parsing from bash, plus Find-LatestToolkitVersion from PowerShell.

Behavior change: bash downloads straight into the install directory

The bash installer used to download to $TMPDIR and fall back to the install directory when the temp directory was full. Now it always downloads into the directory sentry cli setup installs into, as setup's own temp file (sentry.download). Setup renames it into place instead of copying it, and a small or full /tmp no longer matters. This removes write_staged and the fallback paths.

Side effects:

  • The installer creates the install directory before setup runs.
  • If the installer is killed with SIGKILL, a partial sentry.download can be left behind. Normal exits and Ctrl-C clean it up.
  • The out-of-space error now points at SENTRY_INSTALL_DIR instead of TMPDIR.

Porting to POSIX sh is out of scope. The script depends on the bash ERR trap and $BASH_COMMAND reporting, arrays, nocasematch, and printf -v.

via @evanpurkhiser, @BYK.

--

View Session [Sentry]

Restructure both installers around a short happy path: bash main() and
PowerShell Invoke-Install now read as the list of install steps, and each
step is a small named helper with a comment saying what it does and why.
Nested branches become guard clauses, repeated failure handling becomes one
helper, and the bash script runs main on its last line so a truncated
download executes nothing.

Behavior, messages, telemetry steps, and setup arguments are unchanged. The
only test change follows from the trap now naming main() as the function.

Co-Authored-By: Evan Purkhiser <1421724+evanpurkhiser@users.noreply.github.com>
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 18, 2026 10:04pm UTC
sentry-local Ready Ready Preview Nov 18, 2026 10:04pm UTC

Request Review

The bash installer now downloads into the directory `sentry cli setup`
installs into, as setup's own temp file (sentry.download), instead of
$TMPDIR with a fallback to that directory when the temp directory is full.
Setup renames the download into place, a small or full /tmp no longer
matters, and write_staged and the fallback paths go away.

Co-Authored-By: Evan Purkhiser <1421724+evanpurkhiser@users.noreply.github.com>
When Sentry's release registry is down, an unpinned install now fails with
"Failed to fetch latest stable version... install a specific version"
instead of paging through GitHub releases for the newest stable cli@ tag.
A pinned version still downloads from its GitHub release. This removes the
GitHub API client, its rate-limit and token handling, and the release-page
parsing from install, and Find-LatestToolkitVersion from install.ps1.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9b6cc85. Configure here.

Comment thread packages/cli/install Resolved

This branch was successfully deployed

2 active deployments
Preview – cli — 9b6cc856 Deployed Nov 18, 2026 by vercel[bot]
Preview – sentry-local — 9b6cc856 Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant