rn-diff-purge: Error when try to update RN@0.59.4 to RN@0.59.5

Trying to update my app gives me the error below. So I create a new fresh app with react-native init Example --version 0.59.4, try to run the upgrade and get same error error again.

$ react-native upgrade 0.59.5 --verbose
info Fetching diff between v0.59.4 and v0.59.5...
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.59.5
• Comparison between versions: https://github.com/react-native-community/rn-diff-purge/compare/version/0.59.4..version/0.59.5
• Git diff: https://github.com/react-native-community/rn-diff-purge/compare/version/0.59.4..version/0.59.5.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/lucianolima/projetos/oss/Example/node_modules/@react-native-community/cli/build/commands/upgrade/upgrade.js:292:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)

My RN info:

  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
      Memory: 4.32 GB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
      Yarn: 1.13.0 - ~/.nvm/versions/node/v10.15.3/bin/yarn
      npm: 6.9.0 - ~/.nvm/versions/node/v10.15.3/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:
        Build Tools: 23.0.3, 24.0.3, 25.0.3, 26.0.1, 26.0.3, 27.0.3, 28.0.3
        API Levels: 23, 24, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5314842
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.4 => 0.59.4
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

I had the same problem when trying to upgrade RN from 0.59.9 to 0.60. here is the error that i got:

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

After spending a few hours of googling ( because i don’t want to manually upgrade 😃 ), here is what i did to solve the problem:

  1. run npm uninstall -g react-native-cli to uninstall legacy react-native-cli
  2. go to here https://github.com/react-native-community/cli#updating-the-cli to upgrade the local react-native-cli
  3. run yarn react-native upgrade 0.60.0 at your project’s root directory ( i am using yarn, it should be fine with npm too, i guess)

I hope by posting this it can save someone’s time if they are having the same problem

I’ll try to explain a bit more.

So if you go the manual way, yes, you need to do the changes. I usually type them out if it’s small or copy paste if its bigger. While doing that, pay attention to what you change. Try to understand what this changes for you and your project and why.

Screen Shot 2019-07-04 at 09 47 18

This for example has a change in the start script, and it now uses the react-native command, so you should too. Also it adds a lint script, which you might already have, so you could skip this one if you don’t care or if you have a better one already.

The path is the title of the box. So in the above example its package.json on your project root. Screen Shot 2019-07-04 at 09 49 13 Here its ios/RnDiffApp/Info.plist. RnDiffApp is a “magic” string, which takes the place of your project name. If your project name is TimJungRules, then the path is ios/TimJungRules/Info.plist.

The text you mention in the Podfile is a comment on the diff, to explain the change a bit. Specifically for this change, all the native libraries that make React Native have been removed from the project and added to pods. They used to be linked in the project directly, and now they are not there anymore. Now they live in the pods, and the pods are linked bunched up as one to your project. So the comment was just a quick explanation of that, and to show that you can add more pods there from other libs/deps you might have. The Podfile is for iOS native what package.json is for js.

I hope this helped, and thanks for the questions. I am compiling a bunch of them to address as many as possible.

I had the same problem when trying to upgrade RN from 0.59.9 to 0.60. here is the error that i got:

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

After spending a few hours of googling ( because i don’t want to manually upgrade 😃 ), here is what i did to solve the problem:

  1. run npm uninstall -g react-native-cli to uninstall legacy react-native-cli
  2. go to here https://github.com/react-native-community/cli#updating-the-cli to upgrade the local react-native-cli
  3. run yarn react-native upgrade 0.60.0 at your project’s root directory ( i am using yarn, it should be fine with npm too, i guess)

I hope by posting this it can save someone’s time if they are having the same problem

It works!!!

@pvinis Thanks for the reply. It makes me sad too but it’s okay. 😃 I think after evaluating my libraries anyway I think it’s best to wait some time for them to update to supporting 60 anyway. Hopefully by then the upgrade process might make more sense to me.

If you have any articles or resources for understanding cocoapods with react native too that might be useful to know about. If not that’s okay too. Thanks again.

this makes me sad to hear 😦

Of course everything cannot be 1 to 1, since we base the upgrade on the RN template project, so if anyone uses another template, or has changed the setup a bit, or many other things, they have to do it manually and decide which changes are relevant to them.

It’s always a bit harder when big changes are introduced like cocoapods in the case of 60. One thing you could try is to make a new project, see how the libs are connected with pods and in Xcode, and try to recreate it for your project.

That’s why specifically for Xcode project I say that it doesn’t have to be exact, but the “form” should be similar. maybe you have 5 targets. that means your diff will be 5 times bigger. maybe you use xcconfigs, you diff will be there too and not just the project file, etc.

So there is this.

If you want you can use react-native upgrade or just manually make the changes for everything else.

For the xcode project file, there is a comment in the above link that points to here that gives more info about the change and how to make it.

If you mean another file and I misunderstood, comment again and give more info. Thanks and good luck 😃