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
- Use a pnpm workspace React Native app with
@sentry/react-native installed.
- Do not install
@sentry/cli as a direct app dependency.
- Run the resolver from a native project directory such as
android/ or ios/:
node --print "require.resolve('@sentry/cli/package.json')"
- 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
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; currentmainstill has the same direct resolver pattern inpackages/core/sentry.gradle.ktsand both iOS scripts.Description
The Android Gradle integration and iOS Xcode scripts try to locate
@sentry/cliwith a direct Node resolution from the native project directory:That does not work reliably with package managers that isolate dependencies, such as pnpm.
@sentry/cliis installed as a dependency of@sentry/react-native, but it is not necessarily directly resolvable fromandroid/orios/.Resolving the CLI from the
@sentry/react-nativepackage context works in this layout:Steps to Reproduce
@sentry/react-nativeinstalled.@sentry/clias a direct app dependency.android/orios/:node --print "require.resolve('@sentry/cli/package.json')"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-clipackage shipped through@sentry/react-nativewithout requiring applications to add@sentry/clias a direct dependency or set a manual executable override.Actual Result
Plain
require.resolve('@sentry/cli/package.json')can fail with:The dependency-relative resolver returns the installed pnpm store path for
@sentry/cli, allowing the scripts to computebin/sentry-clicorrectly.Proposed Fix
Use dependency-relative resolution in:
packages/core/sentry.gradle.ktspackages/core/scripts/sentry-xcode.shpackages/core/scripts/sentry-xcode-debug-files.shThe existing pnpm shim fallback can stay in place as a fallback path.
Related