sentry-react-native: index.android.bundle.hbc.e6d69f: No such file or directory
Environment
How do you use Sentry? Sentry SaaS (sentry.io)
Which SDK and version?
"@sentry/react-native": "2.6.2",
Steps to Reproduce
Tried to upgrade my project from React Native 0.63.4 to 0.65.1 and enable hermes for Android.
I am using a monorepo and have the following in my build.gradle
:
project.ext.react = [
cliPath: "../../../node_modules/react-native/cli.js",
composeSourceMapsPath: "../../../node_modules/react-native/scripts/compose-source-maps.js",
enableHermes: true, // clean and rebuild if changing
entryFile: "index.js",
hermesCommand: "../../../../../node_modules/hermes-engine/%OS-BIN%/hermesc",
]
apply from: "../../../../../node_modules/react-native/react.gradle"
apply from: "../../../../../node_modules/@sentry/react-native/sentry.gradle"
Here is my android/sentry.properties
:
defaults.url=https://sentry.io/
defaults.org=myOrganization
defaults.project=myProject
cli.executable=../../../node_modules/@sentry/cli/bin/sentry-cli
Expected Result
Source maps would be handled like before, but with hermes enabled for Android.
Actual Result
I get the following error related to a missing index.android.bundle.hbc
file:
[16:32:20]: ▸ ^~~~~~~~~~~~~~~~
[16:32:26]: ▸ Failed to open file /frontend/applications/myProject/android/app/build/generated/assets/react/dev/release/index.android.bundle.hbc.e6d69f: No such file or directory
[16:32:28]: ▸ DEBUG 2021-09-08 16:32:28.064290 -05:00 sentry-cli version: 1.66.0, platform: "darwin", architecture: "x86_64"
[16:32:28]: ▸ INFO 2021-09-08 16:32:28.065016 -05:00 sentry-cli was invoked with the following command line: "/node_modules/@sentry/cli/sentry-cli" "react-native" "gradle" "--bundle" "/frontend/applications/myProject/android/app/build/generated/assets/react/dev/release/index.android.bundle" "--sourcemap" "/frontend/applications/myProject/android/app/build/generated/sourcemaps/react/dev/release/index.android.bundle.map" "--release" "[REDACTED]" "--dist" "[REDACTED]"
[16:32:28]: ▸ INFO 2021-09-08 16:32:28.072137 -05:00 Issuing a command for Organization: myOrganization Project: myProject
[16:32:28]: ▸ Processing react-native sourcemaps for Sentry upload.
[16:32:28]: ▸ INFO 2021-09-08 16:32:28.072173 -05:00 bundle path: /frontend/applications/myProject/android/app/build/generated/assets/react/dev/release/index.android.bundle
[16:32:28]: ▸ INFO 2021-09-08 16:32:28.072184 -05:00 sourcemap path: /frontend/applications/myProject/android/app/build/generated/sourcemaps/react/dev/release/index.android.bundle.map
[16:32:28]: ▸ error: No such file or directory (os error 2)
[16:32:28]: ▸ DEBUG 2021-09-08 16:32:28.108294 -05:00 client close; no transport to shut down (from sentry)
[16:32:28]: ▸ DEBUG 2021-09-08 16:32:28.108346 -05:00 skipping update nagger because session is not attended
[16:32:28]: ▸ FAILURE: Build completed with 2 failures.
If I disable hermes for Android, it builds without errors.
iOS works fine.
Since I am using a monorepo, is there something I am missing in terms of giving Sentry and/or React Native the paths they need to create the .hbc file?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 23 (11 by maintainers)
I had the same problem and was stuck on this for days. Then by seeing your problem it helped me find the solution, apparently the problem was that in my project rootfolder the folder name contains a space (%20) and that’s why it adds this SHA-1 code or whatever as a file extension after android.index.bundle.hbc… By removing the space the release build now succeeds.
Yes, actually! I finally figured this out a few months ago. Basically, our git branch names look something like
feat/TICKET/description
and Jenkins did not like any of the/
in the workspace path. So, we had to do something like:in our Jenkinsfile to get around it.
As for only happening for monorepo, I would assume so since we have to specify the paths to our root node_modules. Normal repos would have their node_modules where react-native expects to find it.
It works fine with Hermes disabled. It only fails at the point where it creates the .hbc file.
@eliw00d See step 2 here: https://docs.sentry.io/platforms/react-native/manual-setup/hermes/#compile-for-android maybe try switching out the hermesCommand to the correct one with OS-BIN filled out?
We’re not using Hermes currently but maybe this will still help? I don’t recall exactly all the changes we made to get Sentry working in the monorepo but, from what I can relocate:
packages/apps/[app-name]/android/app/build.gradle
:Note, changed
entryFile
and we’re not changing the Sentry cli path there, we’re instead doing it in sentry.properties (I think because that way it also applies to sentry-cli when it’s run via Fastlane)…packages/apps/[app-name]/android/sentry.properties
andpackages/apps/[app-name]/ios/sentry.properties
:App’s iOS ‘Bundle React Native code and images’ build stage script changed to:
(Note extra
--entry-file
option inEXTRA_PACKAGER_ARGS
)App’s iOS ‘Upload Debug Symbols to Sentry’ build stage script changed to:
The number of
../
's in those code blocks will obviously vary depending on your monorepo layout.If it’s still not working for you after all those changes let me know what error you get and maybe I can find what I’ve missed including here.