sentry-react-native: sentry-cli fails in yarn monorepo setup
We have an expo app inside a yarn monorepo workspace and our build fails with:
> Task :app:bundleReleaseJsAndAssets
info Writing bundle output to:, /build/workingdir/build/apps/sh.hae.app/android/app/build/generated/assets/react/release/index.android.bundle
info Writing sourcemap output to:, /build/workingdir/build/apps/sh.hae.app/android/app/build/generated/sourcemaps/react/release/index.android.bundle.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 47 asset files
info Done copying assets
> Task :app:bundleReleaseJsAndAssets_SentryUpload_1 FAILED
> Task :app:bundleReleaseJsAndAssets_SentryUploadCleanUp SKIPPED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
631 actionable tasks: 631 executed
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:bundleReleaseJsAndAssets_SentryUpload_1'.
[stderr] > A problem occurred starting process 'command '/build/workingdir/build/apps/sh.hae.app/node_modules/@sentry/cli/bin/sentry-cli''
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 6m 57s
The call to /build/workingdir/build/apps/sh.hae.app/node_modules/@sentry/cli/bin/sentry-cli
fails because yarn installs @sentry/cli in the workspace root i.e. /build/workingdir/build/node_modules
not inside the apps/sh.hae.app
subdirectory.
This should be the culprit line:
https://github.com/getsentry/sentry-react-native/blob/b7b1372e637d2363a9d43811f332450735524212/sentry.gradle#L95
Expo uses require.resolve
within gradle to find package locations in yarn monorepos. e.g. new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute().text.trim(), "../native_modules.gradle");
maybe this is a possible solution
(first reported to https://github.com/expo/sentry-expo/issues/217)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 16 (6 by maintainers)
Hi! My name is Cedric and I work for Expo, just want to pitch in and find some options to resolve this. With Expo SDK 43, one of the new focuses is adding support for monorepositories. I noticed the hardcoded path in the Gradle script as well. We can resolve this in
sentry-expo
by calculating thecli.executable
path, and if it’s different compared to this “hardcoded path”, we could add the relative location of the Sentry CLI.Is it safe to add that
cli.executable
path? As in, will this be supported for future versions? The documentation around this is fairly limited, so just want to check before we add this on our end 😄I’ve raised this issue https://github.com/getsentry/sentry-react-native/issues/1912 so iOS eventually respects the
cli.executable
config too instead of always hardcoded.@byCedric
cli.executable
is a public config and can be used, although this would only work for Android, since the Gradle bits look for it before callingsentry-cli
See: https://github.com/getsentry/sentry-react-native/blob/master/sentry.gradle#L95
Although for iOS, unfortunately, this is not true, the CLI path has to be changed in the sentry build phase script, usually under the
project.pbxproj
, this is patched by sentry-wizard during install steps, See https://github.com/getsentry/sentry-wizard/blob/master/lib/Steps/Integrations/ReactNative.ts#L248Build phases:
Bundle React Native Code And Images
andUpload Debug Symbols to Sentry
or just search for
@sentry/cli/bin/sentry-cli
and fix the path accordingly.If you still have some issues, you can try this: https://github.com/byCedric/eas-monorepo-example/issues/32#issuecomment-1243816053
We have some code ready to auto-fill the
cli.executable
insentry.properties
with sentry-expo. I would want to add that as a possible way forward as well! (see code here)@HazAT is gonna follow up on this.
indeed,
cli.executable
isn’t documented, let me double-check if this is of internal usage only or it’d be fine to patch it.