Skip to content

Resolve sentry-cli relative to @sentry/react-native in isolated dependency layouts #6241

Closed

Description

@shawnthye-guru

What React Native libraries do you use?

React Native / Expo, with pnpm workspace dependency layout

Are you using sentry.io or on-premise?

sentry.io (SaaS)

@sentry/react-native SDK Version

Observed with @sentry/react-native@7.11.0; current main still has the same direct resolver pattern in packages/core/sentry.gradle.kts and both iOS scripts.

Description

The Android Gradle integration and iOS Xcode scripts try to locate @sentry/cli with a direct Node resolution from the native project directory:

require.resolve('@sentry/cli/package.json')

That does not work reliably with package managers that isolate dependencies, such as pnpm. @sentry/cli is installed as a dependency of @sentry/react-native, but it is not necessarily directly resolvable from android/ or ios/.

Resolving the CLI from the @sentry/react-native package context works in this layout:

require.resolve('@sentry/cli/package.json', {
  paths: [require.resolve('@sentry/react-native/package.json')],
})

Steps to Reproduce

  1. Use a pnpm workspace React Native app with @sentry/react-native installed.
  2. Do not install @sentry/cli as a direct app dependency.
  3. Run the resolver from a native project directory such as android/ or ios/:
node --print "require.resolve('@sentry/cli/package.json')"
  1. Compare that with dependency-relative resolution:
node --print "require.resolve('@sentry/cli/package.json', { paths: [require.resolve('@sentry/react-native/package.json')] })"

Expected Result

The native Android and iOS integrations should resolve the sentry-cli package shipped through @sentry/react-native without requiring applications to add @sentry/cli as a direct dependency or set a manual executable override.

Actual Result

Plain require.resolve('@sentry/cli/package.json') can fail with:

Error: Cannot find module '@sentry/cli/package.json'
Require stack:
- /path/to/app/android/[eval]

The dependency-relative resolver returns the installed pnpm store path for @sentry/cli, allowing the scripts to compute bin/sentry-cli correctly.

Proposed Fix

Use dependency-relative resolution in:

  • packages/core/sentry.gradle.kts
  • packages/core/scripts/sentry-xcode.sh
  • packages/core/scripts/sentry-xcode-debug-files.sh

The existing pnpm shim fallback can stay in place as a fallback path.

Related

Activity

  1. linear-code commented on Jun 1, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jun 1, 2026
  3. shawnthye-guru commented on Jun 1, 2026

    @shawnthye-guru
    ContributorAuthor

    I opened #6242 with the proposed resolver change so maintainers can review the concrete implementation. Happy to adjust the approach if there is a preferred helper or shared resolver pattern for these scripts.

  4. shawnthye-guru commented on Jun 1, 2026

    @shawnthye-guru
    ContributorAuthor

    The replacement PR was auto-closed because this issue does not yet have maintainer discussion. Could a maintainer confirm whether resolving @sentry/cli relative to @sentry/react-native is an acceptable approach?

    The implementation is already prepared on branch shawnthye-guru:fix/sentry-cli-resolution-6241; once the approach is acknowledged I can reopen or create a fresh PR according to the contribution guidelines.

  5. lucas-zimerman commented on Jun 2, 2026

    @lucas-zimerman
    Collaborator

    Thank you for opening this issue and describing the issue with rich details and also taking a chance to open a PR to fix it! we will take a look on the PR

  6. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jun 2, 2026
  7. self-assigned this
    on Jun 8, 2026
  8. github-actions commented on Jun 11, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #6242, which was included in the 8.14.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions