react-native: react-native-git-upgrade fails when using custom android icons?

Good day React Native team, keep up the amazing work!

Description

I’m attempting to upgrade from RN v0.35 to v0.39.1. I first tried upgrading with the traditional react-native upgrade but that method no longer gives you the ability to see a diff for the changed files (which was a really useful feature IMO).

So I opted for the new react-native-git-upgrade, which seems to work. However, after the upgrade is done, there are no physical changes to any of the files in my project.

I keep seeing these errors in the output, which seem awfully different from the rest of the errors:

error: cannot apply binary patch to 'android/app/src/main/res/mipmap-hdpi/ic_launcher.png' without full index line
Falling back to three-way merge...

Here’s the full output of the upgrade, followed by a git status showing no changes made to the project.

$ react-native-git-upgrade
git-upgrade info Check for updates 
git-upgrade info Read package.json files 
git-upgrade info Check declared version 
git-upgrade info Check matching versions 
git-upgrade info Check React peer dependency 
git-upgrade info Check that Git is installed 
git-upgrade info Get information from NPM registry 
git-upgrade info Upgrading to React Native 0.39.1, React ~15.4.0-rc.4 
git-upgrade info Setup temporary working directory 
git-upgrade info Configure Git environment 
git-upgrade info Init Git repository 
git-upgrade info Add all files to commit 
git-upgrade info Commit current project sources 
git-upgrade info Create a tag before updating sources 
git-upgrade info Generate old version template 
git-upgrade info Add updated files to commit 
git-upgrade info Commit old version template 
git-upgrade info Install the new version 
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
git-upgrade info Generate new version template 
git-upgrade info Add updated files to commit 
git-upgrade info Commit new version template 
git-upgrade info Generate the patch between the 2 versions 
git-upgrade info Save the patch in temp directory 
git-upgrade info Reset the 2 temporary commits 
git-upgrade info Apply the patch 
error: patch failed: .gitignore:22
Falling back to three-way merge...
Applied patch to '.gitignore' with conflicts.
error: patch failed: android/app/src/main/java/com/beepyonative/MainApplication.java:8
Falling back to three-way merge...
Applied patch to 'android/app/src/main/java/com/beepyonative/MainApplication.java' with conflicts.
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-hdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-hdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-hdpi/ic_launcher.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-mdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-mdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-mdpi/ic_launcher.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xhdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xhdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: patch does not apply
error: patch failed: ios/BeepyoNative.xcodeproj/project.pbxproj:22
Falling back to three-way merge...
Applied patch to 'ios/BeepyoNative.xcodeproj/project.pbxproj' with conflicts.
error: patch failed: ios/BeepyoNative/Info.plist:45
Falling back to three-way merge...
Applied patch to 'ios/BeepyoNative/Info.plist' cleanly.
git-upgrade WARN The upgrade process succeeded but there might be conflicts to be resolved. See above for the list of files that have merge conflicts. 
git-upgrade info Upgrade done 

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

Reproduction

Assuming my hunch about the android icons is correct…

  • Add custom ic_loader.png files in a non-current React Native project
  • cd path/to/project
  • react-native-git-upgrade
  • The upgrade does not actually get applied

Solution

  • More clarity as to why the upgrade did not get applied.
  • Possibly a bug fix if app icon conflicts really are hosing the upgrade.

Additional Information

  • React Native version: 0.35
  • Platform: iOS, Android
  • Operating System: macOS

About this issue

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

Commits related to this issue

Most upvoted comments

Adding the exclude option fixes the issue related to custom icons but in my case I still see an error related to project.pbxproj.

$ git apply --exclude=*.png /var/folders/lz/d392c5b17p1dcyhzbn2yrpsh0000gn/T/react-native-git-upgrade/upgrade_0.38.1_0.39.2.patch
error: patch failed: ios/MyProject.xcodeproj/project.pbxproj:22
error: ios/MyProject.xcodeproj/project.pbxproj: patch does not apply

Do you guys have any idea on how to fix this ? Thanks.

Thanks for the detailed report 🤓

We want the git apply command run by react-native-git-upgrade under the hood to ignore these files. I think the exclude option of the apply should do the trick.

In the meantime, here is a dirty workaround:

Git provides 3 different “ignore” files:

  • Project-specific: .gitignore
  • Repo-specific: .git/info/exclude
  • Env-specific: $HOME/.gitignore

We can’t rely on the first one because it is overrided by the upgrading process. We can’t rely on the second as well because we create a temporary repository on-the-fly. Let’s use the third:

$ echo "*.png" > ~/.gitignore  # Tell ALL your repos to ignore PNG files 
$ react-native-git-upgrade # It should be working now
$ rm ~/.gitignore # IMPORTANT don't forget to delete this file otherwise, ALL your repos would ignore the PNG files

Hello!

After I run the command, my dependencies are upgraded inside node_modules but my package.json is not updated, is that normal? Also the build doesn’t work anymore, after running the upgrade command my project.pbxproj from xcode project gets deleted. Reverting it with git brings back the file, but the build is still not working.

This is the log after the react-native-git-upgrade:

$ react-native-git-upgrade
git-upgrade info Check for updates
git-upgrade info Read package.json files
git-upgrade info Check declared version
git-upgrade info Check matching versions
git-upgrade info Check React peer dependency
git-upgrade info Check that Git is installed
git-upgrade info Get information from NPM registry
git-upgrade info Upgrading to React Native 0.40.0, React ~15.4.0-rc.4
git-upgrade info Setup temporary working directory
git-upgrade info Configure Git environment
git-upgrade info Init Git repository
git-upgrade info Add all files to commit
git-upgrade info Commit current project sources
git-upgrade info Create a tag before updating sources
git-upgrade info Generate old version template
git-upgrade info Add updated files to commit
git-upgrade info Commit old version template
git-upgrade info Install the new version
npm WARN jest-react-native@16.0.0 requires a peer of whatwg-fetch@^1.0.0 but none was installed.
git-upgrade info Generate new version template
git-upgrade info Add updated files to commit
git-upgrade info Commit new version template
git-upgrade info Generate the patch between the 2 versions
git-upgrade info Save the patch in temp directory
git-upgrade info Reset the 2 temporary commits
git-upgrade info Apply the patch
error: patch failed: .gitignore:22
Falling back to three-way merge...
Applied patch to '.gitignore' with conflicts.
error: patch failed: android/app/src/main/java/com/sealjobs/MainApplication.java:8
Falling back to three-way merge...
Applied patch to 'android/app/src/main/java/com/sealjobs/MainApplication.java' with conflicts.
error: ios/sealJobs.xcodeproj/project.pbxproj: does not exist in index
error: patch failed: ios/sealJobs.xcodeproj/xcshareddata/xcschemes/sealJobs.xcscheme:37
Falling back to three-way merge...
Applied patch to 'ios/sealJobs.xcodeproj/xcshareddata/xcschemes/sealJobs.xcscheme' cleanly.
error: patch failed: ios/sealJobs/AppDelegate.m:9
Falling back to three-way merge...
Applied patch to 'ios/sealJobs/AppDelegate.m' with conflicts.
git-upgrade WARN The upgrade process succeeded but there might be conflicts to be resolved. See above for the list of files that have merge conflicts.
git-upgrade info Upgrade done
$ git status
On branch improvements/bug-fixes-and-tweaks
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   android/app/src/main/res/mipmap-hdpi/ic_launcher.png
	modified:   android/app/src/main/res/mipmap-mdpi/ic_launcher.png
	modified:   android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
	modified:   android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
	deleted:    ios/sealJobs.xcodeproj/project.pbxproj

no changes added to commit (use "git add" and/or "git commit -a")

The build error that I get:

** BUILD FAILED **


The following build commands failed:

	CompileC /Users/razvan/Projects/sealJobs/ios/build/Build/Intermediates/RCTText.build/Debug-iphonesimulator/RCTText.build/Objects-normal/x86_64/RCTTextManager.o RCTTextManager.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
	CompileC /Users/razvan/Projects/sealJobs/ios/build/Build/Intermediates/RCTNetwork.build/Debug-iphonesimulator/RCTNetwork.build/Objects-normal/x86_64/RCTNetworkTask.o RCTNetworkTask.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
	CompileC /Users/razvan/Projects/sealJobs/ios/build/Build/Intermediates/RCTNetwork.build/Debug-iphonesimulator/RCTNetwork.build/Objects-normal/x86_64/RCTDataRequestHandler.o RCTDataRequestHandler.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
	CompileC /Users/razvan/Projects/sealJobs/ios/build/Build/Intermediates/RCTFBSDK.build/Debug-iphonesimulator/RCTFBSDK.build/Objects-normal/x86_64/RCTFBSDKAppEvents.o RCTFBSDK/core/RCTFBSDKAppEvents.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(4 failures)

Anybody has a clue of what’s going on? I am trying to upgrade from RN@0.36.1 to latest on a MacOS machine.

I needed to run git config --global core.excludesfile '~/.gitignore in order to use the workaround

@hramos, this issue should absolutely stay open. There are a lot of people reporting this issue, and no one to pick up the problem. This is a really pressing problem as it removes a lot of the kind of code that takes a while to figure out, so we are all stuck rebuilding our projects from square one. react-native-git-upgrade should absolutely not be used until this can be fixed.

I upgrade my project from RN0.32.1 to RN 0.44.0, I can’t open my project, and I lost some files.

I lost my files under the project folder