Cli: Error applying patch during react-native upgrade

Created on 4 Jul 2019  Â·  5Comments  Â·  Source: react-native-community/cli

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 3.89 GB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.15.2 - /usr/local/opt/node@10/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/opt/node@10/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.3, 26.0.2, 27.0.3, 28.0.0, 28.0.3
        System Images: android-15 | Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-25 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5522156
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.9 => 0.59.9
    npmGlobalPackages:
      react-native-cli: 2.0.1

Description

I'm trying to upgrade from react-native 59.9 to 60.0 using react-native upgrade. I'm getting the following error when trying to do so.

info No version passed. Fetching latest...
info Fetching diff between v0.59.9 and v0.60.0...
info Applying diff (excluding: package.json)...
error: git diff header lacks filename information when removing 2 leading pathname components (line 5)
error Automatically applying diff failed
error Patch failed to apply for unknown reason. Please fall back to manual way of upgrading
info You may find these resources helpful:
• Release notes: https://github.com/facebook/react-native/releases/tag/v0.60.0
• Comparison between versions: https://github.com/react-native-community/rn-diff-purge/compare/version/0.59.9..version/0.60.0
• Git diff: https://github.com/react-native-community/rn-diff-purge/compare/version/0.59.9..version/0.60.0.diff
error Upgrade failed. Please see the messages above for details
debug Error: Upgrade failed. Please see the messages above for details
    at Object.upgrade [as func] (/Users/brandoneverett/Documents/Development/React/TheTable/node_modules/@react-native-community/cli/build/commands/upgrade/upgrade.js:292:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)

This is a customized react-native project that includes some cocoa pods already and some linked libraries, is this to far gone that I will have to manually upgrade every time?

Another thing I did in trying to pinpoint the problem was installed a clean react-native project at 59.9 and then ran react-native upgrade from that project at it was able to successfully upgrade without the error.

This leads me to think it has something to do with my project. Any help would be appreciated! I would love to be able to use the automated tool, instead of having to upgrade manually every time

Reproducible Demo

Clone the project https://github.com/bmeverett/TheTable and checkout branch rewrite. Run react-native upgrade --verbose and observe the error message.

bug

Most helpful comment

@bmeverett I think I know what the issue is. Can you please update the @react-native-community/cli to the latest 1.x version? Remove it from the lockfile and run install again, then try upgrading once more.

All 5 comments

This error happens because of wrongly generated diff in rn-diff-purge project. I thought they fixed that but likely not every diff. Cc @pvinis
Also please make sure you're on the latest cli before upgrading, we pushed some nice improvements there (delete cli entry in lock file and reinstall)

i can try this tomorrow. all the diffs should be correct now.

@bmeverett I think I know what the issue is. Can you please update the @react-native-community/cli to the latest 1.x version? Remove it from the lockfile and run install again, then try upgrading once more.

Yea so I deleted my lock file and reran yarn install and then the upgrade command and it worked! Thanks guys!

Was this page helpful?
0 / 5 - 0 ratings