react-native: Yoga.podspec has unstable checksum

Old Version

0.72.10

New Version

0.73.5

Description

When perform an upgrade from 0.72.x to 0.73.x I get a difference in build output between my local build and the build we’re running on our CI. The checksum for the Yoga.podspec is different (I have ran pod update Yoga locally to ensure this is not due to caching).

After comparing the generated podspec json file for Yoga locally with the resolved one on CI I can see that the ordering of the elements of the private_header_files key is different. On my CI the file names are sorted alphabetically, while locally the order I’ve gotten seems sort of arbitrary.

My local ruby version is: ruby --version ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [arm64-darwin22]

On CI we’re running: Default Ruby: 3.1.4

So the difference ruby versions may or may not be relevant here.

According to the ruby documentation, Dir.glob does not guarantee the order of its returned values: https://ruby-doc.org/core-2.6.3/Dir.html#method-c-glob

Case sensitivity depends on your system (File::FNM_CASEFOLD is ignored), as does the order in which the results are returned.

Use of that was introduced in https://github.com/facebook/react-native/commit/33ebb5d6365c3dd5d5214afc42c373d265280e27, which first shipped as part of RN 0.73

Steps to reproduce

Run pod install in a fresh react native 0.73 repo locally and commit the lockfile. When running on CI or another computer, you’ll get a diff in the lockfile (or an error if you’re running with the flag --deployment).

Affected Platforms

Build - MacOS

Output of npx react-native info

System:
  OS: macOS 13.6.4
  CPU: (10) arm64 Apple M2 Pro
  Memory: 94.03 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: ~/.nvm/versions/node/v20.10.0/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.3
    path: ~/.nvm/versions/node/v20.10.0/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.13.0
    path: /Users/stiaje/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "23"
      - "26"
      - "27"
      - "28"
      - "29"
      - "30"
      - "31"
      - "33"
    Build Tools:
      - 23.0.1
      - 25.0.2
      - 25.0.3
      - 26.0.1
      - 26.0.2
      - 27.0.0
      - 27.0.3
      - 28.0.2
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
    System Images:
      - android-30 | Google APIs Intel x86 Atom
      - android-31 | Google APIs Intel x86 Atom_64
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.11005911
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.6
    path: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/javac
  Ruby:
    version: 2.7.8
    path: /Users/stiaje/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.5
    wanted: 0.73.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

> pod install
[...]
Verifying no changes
[!] There were changes to the lockfile in deployment mode:
SPEC CHECKSUMS:
  Yoga:
    New Lockfile: a716eea57d0d3430219c0a5a233e1e93ee931eb7
    Old Lockfile: 9e6a04eacbd94f97d94577017e9f23b3ab41cf6c

make: *** [install] Error 1

Reproducer

https://github.com/stianjensen/test-rn-73-pod-install

(The reproduce also shows a diff in the glog spec. That is caused by GitHub actions CI running Xcode 14.2 while I’m running Xcode 15 locally. This difference affects the DEFINES_MODULE flag in the glog podspec)

Screenshots and Videos

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I applied the following patch locally (with patch-package), and it seems to have made things more stable for me (with a new checksum 134d218bd3cc6a4efa72eccf363aa13817749e92):

diff --git a/node_modules/react-native/ReactCommon/yoga/Yoga.podspec b/node_modules/react-native/ReactCommon/yoga/Yoga.podspec
index 2288fbc..61bd492 100644
--- a/node_modules/react-native/ReactCommon/yoga/Yoga.podspec
+++ b/node_modules/react-native/ReactCommon/yoga/Yoga.podspec
@@ -59,6 +59,6 @@ Pod::Spec.new do |spec|
   # Fabric must be able to access private headers (which should not be included in the umbrella header)
   all_header_files = 'yoga/**/*.h'
   all_header_files = File.join('ReactCommon/yoga', all_header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
-  spec.private_header_files = Dir.glob(all_header_files) - Dir.glob(public_header_files)
+  spec.private_header_files = Dir.glob(all_header_files).sort_by(&:upcase) - Dir.glob(public_header_files).sort_by(&:upcase)
   spec.preserve_paths = [all_header_files]
 end

This worked for me

Yeah, @stianjensen is right. I think that something changed in how glob works. To exclude the problem, can you try to use the same ruby version you have in CI? You can use rbenv or any other ruby version manager to check that.

To me it looks like this particular case is not related to absolute paths, but rather something with the ordering (The checksum is a sha1 calculated from the json representation of the podspec, so ordering of content in that file is also important).

Checking for absolute paths was the first thing I looked for, though, given the history of this problem.

I applied the following patch locally (with patch-package), and it seems to have made things more stable for me (with a new checksum 134d218bd3cc6a4efa72eccf363aa13817749e92):

diff --git a/node_modules/react-native/ReactCommon/yoga/Yoga.podspec b/node_modules/react-native/ReactCommon/yoga/Yoga.podspec
index 2288fbc..61bd492 100644
--- a/node_modules/react-native/ReactCommon/yoga/Yoga.podspec
+++ b/node_modules/react-native/ReactCommon/yoga/Yoga.podspec
@@ -59,6 +59,6 @@ Pod::Spec.new do |spec|
   # Fabric must be able to access private headers (which should not be included in the umbrella header)
   all_header_files = 'yoga/**/*.h'
   all_header_files = File.join('ReactCommon/yoga', all_header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
-  spec.private_header_files = Dir.glob(all_header_files) - Dir.glob(public_header_files)
+  spec.private_header_files = Dir.glob(all_header_files).sort_by(&:upcase) - Dir.glob(public_header_files).sort_by(&:upcase)
   spec.preserve_paths = [all_header_files]
 end