expo-monorepo-example icon indicating copy to clipboard operation
expo-monorepo-example copied to clipboard

EAS Build looks in wrong place for Sentry CLI

Open jamesisaac opened this issue 3 years ago • 6 comments

Hi there, thanks for the recent work in improving monorepo support in Expo 43, much appreciated.

I've followed along closely to the changes here and in Expo 43, and attempted to follow a similar migration path for one of my projects (Expo Managed workflow) so it can take advantage of EAS Build and Submit.

It has worked well overall, and I was able to get an Expo 43 monorepo project building on EAS Build for iOS and Android. However, when I then try and do the final remaining step of removing expo-yarn-workspaces (which seemed necessary as it was causing issues in the Expo Web app), this breaks the mobile app under EAS Build on the Sentry step. The error reported by EAS Build servers suggests that it's looking in the child package node_modules folder for Sentry, which it won't be able to find anymore as expo-yarn-workspaces is not doing symlinking.

Android error from EAS build log

[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:bundleReleaseJsAndAssets_SentryUpload_42'.
[stderr] > A problem occurred starting process 'command '/build/workingdir/build/packages/mobile/node_modules/@sentry/cli/bin/sentry-cli''

iOS error from EAS build log

› Executing RapidStaging » Bundle React Native code and images

❌  error: No such file or directory (os error 2)

I've checked carefully and do believe I'm following all the relevant steps for Sentry setup.

packages/mobile/app.config.js snippet

module.exports = () => {
  // ...
  return {
    expo: {
      // ...
      plugins: ['sentry-expo'],
      hooks: {
        postPublish: [
          {
            file: 'sentry-expo/upload-sourcemaps',
            config: {
              organization: 'redacted',
              project: 'redacted',
              authToken: 'redacted',
            },
          },
        ],
      },
    },
  };
};

packages/mobile/package.json snippet

  "dependencies": {
    "@sentry/react-native": "^2.6.0",
    "expo": "^43.0.2",
    "sentry-expo": "^4.0.0",
  },

Is there some way of hinting to the sentry-expo "plugin" that the project is a monorepo, so it can make the appropriate adjustments for locating Sentry CLI? Everything I'm reading says that in Expo 43 symlinking with expo-yarn-workspaces is no longer necessary and module resolution should just work, but that doesn't seem to be the case here.

yarn.lock package versions:

  • @sentry/react-native: 2.6.2
  • expo: 43.0.2
  • sentry-expo: 4.0.3

jamesisaac avatar Nov 08 '21 20:11 jamesisaac

Hi @jamesisaac! We are working with Sentry to get this resolved asap, you can follow along here https://github.com/getsentry/sentry-react-native/issues/1857

byCedric avatar Nov 09 '21 17:11 byCedric

Excellent, thanks! Sorry, presumed sentry-expo was in the expo monorepo, or I would have spotted https://github.com/expo/sentry-expo/issues/217

jamesisaac avatar Nov 09 '21 18:11 jamesisaac

No worries! We probably will encounter this for some libraries in the future. But, we are actively trying to solve these types of issues either on our (Expo) side, or with the library maintainers. I'm glad you are one of the community members who warns us of these types of issues, so we can resolve them. Thanks for that ❤️

byCedric avatar Nov 09 '21 19:11 byCedric

I managed to make it work in ejected and not ejected expo projects. The problem only occurred in monorepo; the main problem is that the Sentry CLI path is hardcoded.

Ejected Expo:

This https://github.com/expo/sentry-expo/issues/217#issuecomment-979878785 (iOS section) will do the project to build with EAS correctly.

Not ejected Expo:

By adding nohoist option to yarn workspace:

"nohoist": [
    "@react-native-community/cli-platform-ios",
    "@react-native-community/cli-platform-android",
    "@sentry/cli",
    "@sentry/react-native",
    "expo",
    "react-native",
    "jsc-android",
    "hermes-engine",
    "sentry-expo"
  ]

czystyl avatar Sep 12 '22 14:09 czystyl

That's definitely a good workaround for now. At least until https://github.com/getsentry/sentry-react-native/issues/1912 is solved. If Sentry respects the path on iOS (on Android they already do I believe), we can actually use that instead of the workaround.

byCedric avatar Sep 15 '22 21:09 byCedric

@byCedric still seeing this issue in a monorepo with expo 48 image My error is a little bit different but i assume it is related. Build passes for android. Im using npm so I don't have the nohoist option, is there another work around?

farmstrong8 avatar Jun 15 '23 00:06 farmstrong8