Skip to content

feat(cli): Fail clearly when v3 scripts call sentry-cli - #2929

Merged
BYK merged 1 commit into
mainfrom
junior/cli-sentry-cli-shim
Dec 5, 2026
Merged

BYK merged 1 commit into
mainfrom
junior/cli-sentry-cli-shim

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

v4 installs only sentry. A v3 script that calls sentry-cli gets "command not found". If the script saved a v4 binary as sentry-cli, it runs v4 commands it wasn't written for. Both cases now fail the same way: a message that says what changed, then exit code 1. It never runs sentry.

Before:

$ sentry-cli releases new 1.0
sh: 1: sentry-cli: not found        # exit 127

After:

$ sentry-cli --version
Error: sentry-cli is now sentry. Sentry CLI v4 renamed the command and changed some commands and flags.
Update your scripts: https://cli.sentry.dev/migrating-from-v3/
Or stay on v3:
  npm:     npm install @sentry/cli@3
  pip:     pip install "sentry-cli<4"
  get-cli: curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=3.8.2 sh
# exit 1
  • Binary: bin.ts shows the message when the process runs as sentry-cli or sentry-cli.exe. It checks argv0 (the name the binary was invoked as, which keeps a symlink's name) and the binary's own file name. Run as sentry, nothing changes, and the hidden v3 aliases still work. The npm package runs under node, so the check never fires there.
  • PyPI sentry-cli: the wheels add a sentry-cli console script. pip writes a launcher for it on every platform, sentry-cli.exe on Windows.
  • npm @sentry/cli is left out on purpose. A second bin would break npx @sentry/cli … (npm: "could not determine executable to run") and pnpm dlx @sentry/cli …, which run v4 sentry today.
  • get-cli (install) comes in a follow-up, after fix(cli): Install v3 on old glibc and make the installer POSIX sh #2927.

The message and exit code live in src/lib/sentry-cli-rename.ts.

via @BYK.

--

View Session [Sentry]

v4 installs only `sentry`, so scripts written for v3 that call
`sentry-cli` exit 127 with "command not found", or, when they saved the
v4 binary as `sentry-cli`, run v4 commands they were not written for.
Both now print that the command is now `sentry`, link the migration
guide, list the v3 pins, and exit 1. Neither runs `sentry`.

- The binary checks the name it runs as (argv0 or its own file name):
  `sentry-cli` or `sentry-cli.exe` gets the message. As `sentry`,
  nothing changes, hidden v3 aliases included.
- PyPI `sentry-cli`: a `sentry-cli` console script, so pip writes a
  launcher on every platform.

npm `@sentry/cli` is left as is: a second bin would make
`npx @sentry/cli` fail with "could not determine executable to run".

The message and exit code live in src/lib/sentry-cli-rename.ts.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@sentry-junior
sentry-junior Bot requested a review from BYK December 5, 2026 04:53
@vercel

vercel Bot commented Dec 5, 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 Dec 5, 2026 4:53am UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Dec 5, 2026 4:53am UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 5, 2026
sentry-junior Bot added a commit that referenced this pull request Dec 5, 2026
The v4 binary run as sentry-cli and the PyPI sentry-cli command print a
rename notice with the v3 pins and exit 1 (#2929).

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

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Make sure this is compatible with our v3 shim published as part of our migration guide

@BYK
BYK added this pull request to the merge queue Dec 5, 2026
@sentry-junior

sentry-junior Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Make sure this is compatible with our v3 shim published as part of our migration guide

Checked against the migration guide on main. The full sentry-cli() function (it runs env … sentry), alias sentry-cli='sentry' and the CI one-liner all call the binary by the name sentry, so the rename check never fires for them. Shell functions and aliases also win over a sentry-cli on PATH, so the PyPI sentry-cli command doesn't override them.

I tested the built binary with a copy named sentry-cli first on PATH. With no shim, sentry-cli --version prints the rename message and exits 1. With each shim from the guide, --version, releases --help, upload-dif --help and --auth-token x info --help all exit 0. No code change needed.

via @BYK.

Merged via the queue into main with commit 277417e Dec 5, 2026
23 checks passed
@BYK
BYK deleted the junior/cli-sentry-cli-shim branch December 5, 2026 05:17
github-actions Bot pushed a commit to Fields-Education/sentry-mcp that referenced this pull request Dec 5, 2026
…er (getsentry#2930)

The get-cli installer (`curl https://cli.sentry.dev/install | sh`) puts
only `sentry` on PATH, so v3 scripts that call `sentry-cli` fail with
"command not found". The installer now also writes a POSIX sh
`sentry-cli` next to `sentry`. It prints the same message as
getsentry#2929 (the v4 binary run as `sentry-cli`, and PyPI's
`sentry-cli`) and exits 1. It never runs `sentry`.

Before:

```
$ sentry-cli --version
sh: 1: sentry-cli: not found        # exit 127
```

After:

```
$ sentry-cli --version
Error: sentry-cli is now sentry. Sentry CLI v4 renamed the command and changed some commands and flags.
Update your scripts: https://cli.sentry.dev/migrating-from-v3/
Or stay on v3:
  npm:     npm install @sentry/cli@3
  pip:     pip install "sentry-cli<4"
  get-cli: curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=3.8.2 sh
                                    # exit 1
```

- When another `sentry-cli` is on PATH or already in the install
directory, the installer leaves it alone, so a real v3 install stays. A
marker line lets a later install replace its own copy.
- On glibc older than 2.28, `install_v3` replaces the script before
setup runs, so the real `sentry-cli` 3.8.2 is never overwritten.
- The migration guide's `sentry-cli` function and alias still take
priority over the file on PATH.
- `sentry cli uninstall` does not remove the shim yet.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Af43004685b81a1275821d14a033373dd -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Af43004685b81a1275821d14a033373dd)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Af43004685b81a1275821d14a033373dd/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <126780+BYK@users.noreply.github.com>
github-actions Bot pushed a commit to Fields-Education/sentry-mcp that referenced this pull request Dec 5, 2026
…ers (getsentry#2928)

**Do not merge until `getsentry/sentry-cli:3` exists on Docker Hub.**
The doc points v3 users at that tag, which doesn't exist yet.

Homebrew 6 and later don't follow the `sentry-cli` → `sentry` formula
rename in getsentry/tools under [tap
trust](https://docs.brew.sh/Tap-Trust). The migration guide said `brew
update` moves installs to v4 and `brew pin sentry-cli` keeps v3, which
isn't what happens now:

```
# before
$ brew install getsentry/tools/sentry-cli
Error: Refusing to load formula getsentry/tools/sentry from untrusted tap getsentry/tools.
$ brew upgrade        # existing sentry-cli install: skipped, stays on 3.8.2

# after (documented)
$ brew install getsentry/tools/sentry      # v4, trusts the formula itself
$ brew install --cask sentry-cli           # stay on v3 (homebrew/cask, 3.8.2)
```

The Docker section now points v3 users at `getsentry/sentry-cli:3` and
shows v4 replacements for the two patterns that broke when `latest`
moved to the distroless image:

```dockerfile
# before
COPY --from=getsentry/sentry-cli /bin/sentry-cli /usr/local/bin/sentry-cli
# after
COPY --from=getsentry/sentry-cli:3 /bin/sentry-cli /usr/local/bin/sentry-cli   # v3
COPY --from=getsentry/sentry-cli /usr/local/bin/sentry /usr/local/bin/sentry   # v4
```

GitLab CI jobs that use the image get a v3 (`:3`) and a v4 (`npx
sentry@4` in a `node` image) example, since v4 has no shell.

The "Where v3 was published" section also says what `sentry-cli` does
since getsentry#2929: the v4 binary run as `sentry-cli` and
PyPI's `sentry-cli` command print that the command is now `sentry`, link
the guide and the v3 pins, and exit 1.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A8c3e19f8033286bd7749ab5fefed43cf -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A8c3e19f8033286bd7749ab5fefed43cf)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A8c3e19f8033286bd7749ab5fefed43cf/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <126780+BYK@users.noreply.github.com>

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — face0abd Deployed Dec 5, 2026 by vercel[bot]
Preview – sentry-local — face0abd Deployed Dec 5, 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