Skip to content

fix(cli): Let the React Native wizard finish without a terminal - #2839

Merged
antonis merged 1 commit into
mainfrom
wizard/rn-no-terminal
Dec 3, 2026
Merged

antonis merged 1 commit into
mainfrom
wizard/rn-no-terminal

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

From the mobile re-test (getsentry/sentry-react-native#7172). Even with every feature flag (--tracing --profiling --logs --replay --feedback --no-mcp < /dev/null), sentry wizard reactNative exited 1 at a prompt: bare React Native at "Do you want to run pod install now?", Expo at "Have you successfully sent a test event?". This lets the React Native and Expo wizards finish without a terminal, which the wizard e2e tests in #2572 need.

pod install: new --pod-install/--no-pod-install flag in WIZARD_ANSWER_FLAGS (reactNative only). confirmPodInstall asks through askFlagQuestion and keeps Yes as the default.

Closing question: it only confirms a setup that is already done, so it is skipped when stdin is not a TTY (isatty(0), as guardNonInteractive and auto-login check). Piped stdin that is still open counts as no terminal too. The run then ends with an outro that says Sentry is set up, tells the user to send a test event and check it in Sentry, and links the project's issues page and the sentry-react-native GitHub issues. user-confirmed-first-error is "skipped". With a terminal, it is asked as before.

Expo second run: a metro.config.js that already has Sentry is its own "already-configured" outcome of patchMetroInMemory. It is logged once, with no "Could not patch" error and no copy-paste instructions. Those instructions also asked "Did you apply the snippet above?", which would have stopped a run without a terminal too. Parse and write failures still show them, as #2786 does for app.json.

.gitignore duplicates: Expo's .env.local (addToGitignore) and Flutter's sentry.properties (addProperties) are appended only when no line already is the entry, ignoring surrounding whitespace. The check is gitignoreHasEntry in utils/git.ts. addCliConfigFileToGitIgnore now uses it as well, so whitespace around the entry counts there too. #2796 also changes addCliConfigFileToGitIgnore, but in other lines.

via Antonis Lilis.

--

View Session [Sentry]

`sentry wizard reactNative` with every feature flag and stdin at
`/dev/null` still stopped with exit code 1: bare React Native projects at
"Do you want to run pod install now?" and Expo projects at "Have you
successfully sent a test event?".

- `--pod-install`/`--no-pod-install` answer the pod install question,
  which keeps Yes as its default.
- The closing test event question is only a confirmation, so it is
  skipped when stdin is not a terminal. The run then ends with an outro
  that tells the user to send a test event and check it in Sentry, and
  sets `user-confirmed-first-error` to `skipped`.
- An Expo `metro.config.js` that already has Sentry is its own outcome:
  logged once, without "Could not patch" or the copy-paste instructions
  (which also asked a question).
- `.env.local` (Expo) and `sentry.properties` (Flutter) are appended to
  `.gitignore` only when no line lists them yet. The check is shared with
  `addCliConfigFileToGitIgnore` as `gitignoreHasEntry`.

Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
@vercel

vercel Bot commented Dec 3, 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 3, 2026 2:32pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Dec 3, 2026 2:32pm UTC

Request Review

@antonis

antonis commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Tested cc9877d16 (this branch, which fast-forwards main at 5ea6dcf7e), packed and run as sentry wizard …. Xcode 27.2, JDK 17, Flutter 3.44.1, org sentry-sdks with one project per platform, SENTRY_AUTH_TOKEN unset, default answers. Each project was reset to its pre-wizard state before each run.

Blockers: two questions that this PR doesn't cover still stop a run without a terminal, so check 1 and check 4 exit 1. Both come from shared code that existed before this PR. Everything this PR changes works as described.

# Project Result How checked
1 Bare RN 0.88.1, CocoaPods, --pod-install, no terminal ❌ exit 1 "pod install: yes (--pod-install)", pod install ran (RNSentry in Podfile.lock). It then stops at "Looks like you have Prettier in your project. Do you want to run it on your files?": the RN template ships Prettier. Everything before it is applied (Sentry.init, Metro, Xcode phases, Gradle, token in .env.sentry-build-plugin), and the iOS Debug build succeeds. With Prettier removed from package.json (TEST ONLY), the same command exits 0 and ends with "Sentry is set up! Send a test event with the snippet above…" and the issues link.
2 Same, --no-pod-install ✅ / ⚠️ "pod install: no (--no-pod-install)", no ios/Pods. A manual cd ios && pod install then succeeds ("Pod installation complete!"), and so does the Debug build. The run then stops at the same Prettier question (exit 1). ⚠️ Nothing tells the user to run pod install themselves; the only line is the flag echo.
3 Same, with a terminal, no flags ✅ Exit 0. All questions are asked, including "Do you want to run 'pod install' now?" (answered Yes with Enter) and "Have you successfully sent a test event?", and the run ends with "Everything is set up!".
4 Same app, run 1's command again ❌ exit 1 Stops at "The @sentry/react-native package is already installed. Do you want to update it to the latest version?", which has no flag. Nothing was changed or duplicated before that (Sentry.init 1, Sentry.wrap 1, upload phase 1, sentry.gradle 1, .env.sentry-build-plugin in .gitignore 1).
5 Bare RN 0.88.1 with SwiftPM (react-native spm add --deintegrate), --pod-install ✅ "The iOS project uses Swift Package Manager. The wizard does not change the Podfile and does not run pod install." Podfile unchanged, no ios/Pods. Then the same Prettier stop (exit 1).
6 Expo 58 (create-expo-app@latest), no terminal ✅ Exit 0, ends with "Sentry is set up!". Sentry.init in _layout.tsx, the plugin in app.json, metro.config.js created, token in .env.local.
7 Same Expo app, second run ❌ / ✅ Without a terminal: exit 1 at the same "already installed, update?" question as check 4. With a terminal (defaults): exit 0. Metro: "The metro.config.js file already has Sentry configuration.", with no "Could not patch" and no instructions. .gitignore: ".env.local is already in .gitignore.", grep -c = 1. Plugin: "The Sentry Expo plugin is already set up in app.json." git status clean after the run.
8 Expo, .gitignore already has .env.local (trailing spaces) ✅ Exit 0, ".env.local is already in .gitignore.", and still only that one line.
9 Flutter (flutter create), wizard twice ✅ Both runs exit 0; grep -c '^sentry.properties$' .gitignore = 1 after each.
10 Next.js (create-next-app@latest), wizard twice ✅ Both runs exit 0, "Successfully installed the Sentry Next.js SDK". .env.sentry-build-plugin is in .gitignore once after both runs ("Added … to .gitignore" on the first run only). The second run changes no files. next build compiles.

Safe to merge? Yes. The new flag, the skipped closing question, the Expo Metro message and the .gitignore checks all work, and nothing regressed with a terminal or in Flutter and Next.js. It doesn't yet deliver "finish without a terminal" for a fresh bare React Native app or for any second run, because of the two questions below. They can go in this PR or in a follow-up.

New (not from this PR):

  • The formatter question (runFormatters in utils/clack/index.ts) has no flag and isn't skipped without a terminal. Every bare RN app from the template has Prettier, so this is the common case. A default without a terminal (skip, or run it) or a --prettier/--no-prettier flag would fix it.
  • "@sentry/react-native is already installed. Do you want to update it?" has the same problem on every second run, in both bare RN and Expo. Keeping the installed version without a terminal seems the safe default.
  • --no-pod-install could print the command to run, for example "Run cd ios && pod install before building."

@antonis antonis 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.

Approving. Everything this PR changes works in the real-project test above:

  • --pod-install / --no-pod-install answer the pod install question.
  • The closing question is skipped without a terminal.
  • Expo second run: Metro says "already has Sentry configuration" instead of "Could not patch".
  • .gitignore: entries are checked before appending, including a line with trailing spaces.

Nothing regressed with a terminal, on SwiftPM projects, in Flutter, or in Next.js, which covers the shared .gitignore check. Expo without a terminal now exits 0.

Follow-up, in a separate PR, tracked in #2840: two more questions still stop a run without a terminal.

  • Formatters: "Looks like you have Prettier in your project. Do you want to run it on your files?" (runFormatters in utils/clack/index.ts). It hits every bare React Native app from the template, since the template includes Prettier. With Prettier removed, the bare React Native run exits 0.
  • Updating: "The @sentry/react-native package is already installed. Do you want to update it to the latest version?" (installPackage). It hits every second run, in bare React Native and Expo.

Why they're not covered here: both are shared by every JavaScript-based wizard (Next.js, SvelteKit, Nuxt, Angular, Remix, React Router, Cloudflare, sourcemaps), not just React Native. Changing them affects all of those, so it deserves its own PR and review. It also needs a decision this PR shouldn't make:

  • Option A: answer flags, such as --format/--no-format and --update/--no-update. That's consistent with #2789 and with #2652's rule that an unanswered question stops a run without a terminal.
  • Option B: safe defaults without a terminal: don't run the formatter, and keep the installed version.

I'd go with flags. The same follow-up can also make --no-pod-install print "Run cd ios && pod install before building", since right now the only output is the flag's own log line.

@antonis
antonis marked this pull request as ready for review December 3, 2026 15:08
@antonis
antonis added this pull request to the merge queue Dec 3, 2026
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 3, 2026
Merged via the queue into main with commit 8ddeff1 Dec 3, 2026
32 checks passed
@antonis
antonis deleted the wizard/rn-no-terminal branch December 3, 2026 15:11

This branch was successfully deployed

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