`yarn install` on a clean checkout of main leaves `packages/react-native/package.json` and `yarn.lock` modified

Open
#59,552 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
59/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, react-native

Research direction

Start with the root preinstall script in package.json and scripts/try-set-hermes-compiler-prebuilt.js, then inspect the yarn add call and the root and workspace resolutions. Reproduce from a clean checkout with yarn install --frozen-lockfile and compare git status and the two named files. Done means the install exits without modifying packages/react-native/package.json or yarn.lock.

Written by the indexing model from the issue text.

Description

Needs: Attention Needs: Repro
Description

On a clean checkout of main, yarn install leaves two tracked files modified: packages/react-native/package.json and yarn.lock. --frozen-lockfile does not prevent it.

The root preinstall runs scripts/try-set-hermes-compiler-prebuilt.js. main commits "hermes-compiler": "0.0.0" in packages/react-native/package.json, so the script runs yarn workspace react-native add hermes-compiler@latest-v1 --exact. That yarn add is its own yarn process, so the outer install's --frozen-lockfile does not reach it. It writes the resolved version into the manifest and the lockfile. It also re-sorts the manifest's dependencies, which moves flow-parser, committed out of alphabetical order. Because that yarn add runs in packages/react-native, yarn reads resolutions from that manifest, which has none, so it also rewrites the lockfile entry of every package the root's resolutions pin (react-is, lodash, minimatch, fast-xml-parser, …). Besides the hermes-compiler entry, every yarn.lock change comes from that.

So every fresh clone starts with a dirty tree, and both files are easy to commit by accident; AGENTS.md lists this under Gotchas ("Expected — do not commit it"). I expected the install to leave the tree as committed, and with --frozen-lockfile to fail rather than write yarn.lock.

Steps to reproduce
  1. Check out main in a clean clone (I used f14a251800). git status --short prints nothing.

  2. Run yarn install --frozen-lockfile at the repository root. It exits 0.

  3. Run git status --short. It prints:

     M packages/react-native/package.json
     M yarn.lock
    

Expected: git status --short prints nothing after a frozen install.
Actual: the two tracked files are modified (step 3).

React Native Version

main (1000.0.0, f14a251800)

Affected Platforms

Build - Windows

Output of npx @react-native-community/cli info
npm notice run @react-native/[email protected] npx
npm notice run rnc-cli info
info Fetching system and libraries information...
System:
  OS: Windows 11 10.0.26300
  CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor          "
  Memory: 148.75 GB / 255.67 GB
Binaries:
  Node:
    version: 26.12.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 12.2.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "33"
      - "35"
      - "35"
      - "35"
      - "36"
      - "37"
    Build Tools:
      - 35.0.0
      - 36.0.0
      - 36.1.0
      - 37.0.0
    System Images:
      - android-26 | Google APIs Intel x86_64 Atom
      - android-28 | Google APIs Intel x86_64 Atom
      - android-29 | Google APIs Intel x86_64 Atom
      - android-30 | Google APIs Intel x86_64 Atom
      - android-31 | Google APIs Intel x86_64 Atom
      - android-32 | Google APIs Intel x86_64 Atom
      - android-33 | Google APIs Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
      - android-35 | Google APIs Intel x86_64 Atom
      - android-36.1 | Google Play Intel x86_64 Atom
      - android-36.1 | Pre-Release 16 KB Page Size Google Play Intel x86_64 Atom
      - android-37.0 | Google APIs Intel x86_64 Atom
    Android NDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-262.9437.185.2621.16467767
  Visual Studio: Not Found
Languages:
  Java:
    version: 17.0.20.1
    path: /c/Program Files/Microsoft/jdk-17.0.20.101-hotspot/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native: Not Found
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Stacktrace or Logs
$ yarn install --frozen-lockfile
yarn install v1.22.22
$ node ./scripts/try-set-hermes-compiler-prebuilt.js
Hermes compiler version not set. Updating to the latest-v1 release.
yarn workspace v1.22.22
...
yarn add v1.22.22
...
success Saved lockfile.
success Saved 7 new dependencies.
...
Done in 31.09s.
$ git status --short
 M packages/react-native/package.json
 M yarn.lock
$ git diff -- packages/react-native/package.json
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 5142e53d0a..c1bbcfd436 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -158,10 +158,10 @@
     "@react-native/virtualized-lists": "0.87.0-main",
     "anser": "^1.4.9",
     "ansi-regex": "^5.0.0",
-    "flow-parser": "0.336.0",
     "base64-js": "^1.5.1",
     "flow-enums-runtime": "^0.0.6",
-    "hermes-compiler": "0.0.0",
+    "flow-parser": "0.336.0",
+    "hermes-compiler": "260318099.0.5",
     "invariant": "^2.2.4",
     "memoize-one": "^6.0.0",
     "metro-runtime": "^0.87.2",

yarn.lock changes by 90 insertions and 28 deletions.

MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/react-native-1/tree/reproducer/preinstall-rewrites-tracked-files (main at f14a251800 with no changes: the defect is in the repository's own install, so the steps above run in a fresh clone of it)

Screenshots and Videos

No response

Dominant language
C++
Stars
127k
Forks
25.5k
Avg merge
3d 22h
Merged PRs (30d)
235

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from react/react-native

All issues in react/react-native

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.