Inconsistent information provided when patching fails
See original GitHub issueThis issue seems to be similar to #19 so I updated my yarn and node versions. I am on 64-bit Windows 10 with yarn v1.1.0, node 8.6.0 and npm v5.3.0. I can successfully generate a patch file and I have successfully applied the very same file in the past with $yarn prepare
. I have noticed that this issue seems to occur when I switch branches in git.
$ yarn prepare
yarn run v1.1.0
$ patch-package
patch-package: Applying patches...
**ERROR** Failed to apply patch for package react-native-deprecated-custom-components
This error was caused because react-native-deprecated-custom-components has changed since you
made the patch file for it. This introduced conflicts with your patch,
just like a merge conflict in Git when separate incompatible changes are
made to the same piece of code.
Maybe this means your patch file is no longer necessary, in which case
hooray! Just delete it!
Otherwise, you need to manually fix the patch file. Or generate a new one
To generate a new one, just repeat the steps you made to generate the first
one, but accounting for the changes in react-native-deprecated-custom-components.
i.e. make changes, run `patch-package react-native-deprecated-custom-components`, and commit.
To manually fix a patch file, Run:
patch -p1 -i patches/react-native-deprecated-custom-components+0.1.1.patch --verbose --dry-run
To list rejected hunks. A 'hunk' is a section of patch file that describes
one contiguous area of changes. They are numbered from 1 and begin with lines
that look like this:
diff --git a/node_modules/thing/thing.js b/node_modules/thing/thing.json
Remove the conflicting hunks, then manually edit files in
node_modules/react-native-deprecated-custom-components
to reflect the changes that the conflicting hunks were supposed to make.
Then run `patch-package react-native-deprecated-custom-components`
Info:
Patch was made for version 0.1.1
Meanwhile node_modules/react-native-deprecated-custom-components is version 0.1.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Note that the info: section seems to indicate a belief that the version numbers are out of sync but they are actually identical. Better error messages would be helpful for debugging this.
Here is the package.json file from the library I’m trying to patch in my node_modules folder:
{
"name": "react-native-deprecated-custom-components",
"version": "0.1.1",
"description": "Deprecated custom components that originally shipped with React Native",
"repository": {
"type": "git",
"url": "git@github.com:facebookarchive/react-native-custom-components.git"
},
"main": "src/CustomComponents.js",
"dependencies": {
"fbjs": "~0.8.9",
"immutable": "~3.7.6",
"prop-types": "^15.5.10",
"react-timer-mixin": "^0.13.2",
"rebound": "^0.0.13"
},
"peerDependencies": {
"react-native": "*"
}
}
and here is the patch file itself:
diff --git a/node_modules/react-native-deprecated-custom-components/src/NavigatorBreadcrumbNavigationBar.js b/node_modules/react-native-deprecated-custom-components/src/NavigatorBreadcrumbNavigationBar.js
index 704216e..09efbbe 100644
--- a/node_modules/react-native-deprecated-custom-components/src/NavigatorBreadcrumbNavigationBar.js
+++ b/node_modules/react-native-deprecated-custom-components/src/NavigatorBreadcrumbNavigationBar.js
@@ -93,9 +93,9 @@ class NavigatorBreadcrumbNavigationBar extends React.Component {
titleContentForRoute: PropTypes.func,
iconForRoute: PropTypes.func,
}),
- navState: React.PropTypes.shape({
- routeStack: React.PropTypes.arrayOf(React.PropTypes.object),
- presentedIndex: React.PropTypes.number,
+ navState: PropTypes.shape({
+ routeStack: PropTypes.arrayOf(PropTypes.object),
+ presentedIndex: PropTypes.number,
}),
style: ViewPropTypes.style,
};
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
The risks of failed patch management | TechTarget
Patch management pitfalls include pushing out updates too quickly and devices going offline. But the most significant risk when patch ...
Read more >Patching OMS With the Plugin Update Patch Fails With Error ...
Patching the 13.4 OMS with the Plugin Update patch fails with the error: WARNING: Could not apply the patch "30971925" because the "oracle....
Read more >Recommended Practice for Patch Management of Control ...
The patch management of industrial control systems software used in CIKR is inconsistent at best and nonexistent at worst. Patches are important to...
Read more >How to Give Support Information on False Patch and Other ...
Result Code Result String Description
0x80240002 WU_E_MAX_CAPACITY_REACHED The maximum capacity of the service w...
0x80240003 WU_E_UNKNOWN_ID An ID cannot be found.
0x80240004 WU_E_NOT_INITIALIZED The object could...
Read more >MDVA-33281 patch: inventory inconsistency issues
For info about other patches available in QPT, refer to the Patches available in QPT in our developer documentation. Was this article helpful?...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the .gitattributes change fixed the problem! I decided to document the steps that I followed before I even began the experiment so I’m leaving those steps here in case someone can benefit from them.
Here are the steps I’m using to reproduce this.
The sample app compiles, installs and runs without error. The next step is to add a dependency that requires a patch.
I change line 61 of FBSDKPackage.java to this:
The app compiles and runs so the next step is to generate the patch.
The generated patch file is 132,706 lines long… too big for here so I made it available [here] instead (https://raw.githubusercontent.com/rodnolan/patchpackagetest/master/patches/react-native-fbsdk%2B0.6.1.patch).
Deleted the patch file
reinstated it
dumped node_modules
updated package.json and committed
I tried to re-install dependencies and got this nice new error message:
updated git attributes with the suggested addition, committed that change… (now I understand what you meant by the last comment!)
so I removed the existing patch file again, reapplied the fix, regenerated the patch with
and got this:
That’s more in line with what I expected so I committed that new file and re-installed by dependencies again
Bingo!
Thanks for this fix!
I’ve figured out what’s causing this issue, and it goes away if I re-write the patch files to get rid of CRLFs before applying them, regardless of whether the source files they’re patching have CRLFs or just LFs. I’ll push a fix out tonight.