EAS Prebuild Steps Fails with Yarn Berry

The build fails at the prebuild step. Yarn berry is well configured and integrated such that a local build succeeds. My understanding of the failing looks rather easy to fix on your end: your build service seems to tamper with the package.json file and inject new dependencies. After which the service runs a new yarn install but it looks like the immutable flag is set. Because of those changes in the package.json, the install aborts with the below message:

The lockfile would have been modified by this install, which is explicitly forbidden.

What EAS should do is install in “lax” mode that is yarn install instead of yarn install --immutable

References:

  1. Yarn immutable flag: https://yarnpkg.com/cli/install#options-immutable
  2. Build: Build Details — 7f84ff3d-522b-4895-80b3-777b7cba38df — @jsamr/react-native-render-html-discovery — Expo
  3. Open source reference commit: GitHub - meliorence/react-native-render-html at e94deb72aa7d9a6105b05099166cb25c89512066 (the built project is in apps/discovery)

Managed project require those additional packages to build and autolink native code(both expo packages and any package that supports react-native autolinking). after adding those packages we are running yarn install or npm install depending on what lockfile you have, flag --immutable or any other is not passed there, if sth is enforcing constant lockfile it’s likely inside your project configuration

I have done more research and found out that yarn berry will set the immutable flag when some environment variables are present, namely CI, TEAMCITY_VERSION and perhaps others.
Please refer to this thread: How to run `yarn install` on CI without `--immutable` · Discussion #3486 · yarnpkg/berry · GitHub

The solution would be for your service to set the --no-immutable flag or to set this environment: YARN_ENABLE_IMMUTABLE_INSTALLS=false. I tried setting the later in my eas.json and the prebuild succeeded (see Build Details — 665dafdd-ba27-4f1c-8d7f-24b25b2927f6 — @jsamr/react-native-render-html-discovery — Expo). Now I’m running into other issues out of scope for this thread.

Cheers,

Jules

could you send a pr to update our documentation to explain this requirement for using yarn berry? this would be a good place for it: Integrating with third-party tooling - Expo Documentation

Sure! I’ll try to find the time.

In the meantime, I have updated this quickstarter project with instructions for EAS builds: GitHub - jsamr/yarnberry-expo-quickstarter: Yarn 2 (berry) + React Native / Expo has never been so easy

In case I don’t find the time for a PR, that could be good material for another contributor.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.