This error was caused because patch-package cannot apply the following patch file
I have the following issue when using patch-package, the iOS version fail to install:
dka@dka:[~/workspace/github.com/pass-culture/pass-culture-app-native (PC-16718)]: npx patch-package algoliasearch
patch-package 6.4.7
• Creating temporary folder
• Installing [email protected] with yarn
• Diffing your files with clean files
✔ Created file patches/algoliasearch+4.14.1.patch
💡 algoliasearch is on GitHub! To draft an issue based on your patch run
Then, Circle-CI breaks with:
**ERROR** Failed to apply patch for package algoliasearch at path
node_modules/algoliasearch
This error was caused because patch-package cannot apply the following patch file:
patches/algoliasearch+4.14.1.patch
Try removing node_modules and trying again. If that doesn't work, maybe there was
an accidental change made to the patch file? Try recreating it by manually
editing the appropriate files and running:
patch-package algoliasearch
If that doesn't work, then it's a bug in patch-package, so please submit a bug
report. Thanks!
https://github.com/ds300/patch-package/issues
---
patch-package finished with 1 error(s).
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Exited with code exit status 1
I checked the yarn.lock and :
dka@dka:[~/workspace/github.com/pass-culture/pass-culture-app-native (PC-16718)]: cat yarn.lock | grep algoliasearch
algoliasearch-helper@^3.10.0:
resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.10.0.tgz#59a0f645dd3c7e55cf01faa568d1af50c49d36f6"
algoliasearch@^4.14.1:
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.14.1.tgz#7f24cabd264f8294b461d108e1603e673571e806"
algoliasearch-helper "^3.10.0"
algoliasearch-helper "^3.10.0"
dka@dka:[~/workspace/github.com/pass-culture/pass-culture-app-native (PC-16718)]: cat package.json | grep algoliasearch
"algoliasearch": "^4.14.1",
So everything seems fine, why is this failing?
I have the same issue with CircleCI breaking on patching the package react-native-document-picker
Creation of the patch:
patch-package react-native-document-picker
patch-package 6.4.7
• Creating temporary folder
• Installing [email protected] with yarn
• Diffing your files with clean files
✔ Created file patches/react-native-document-picker+6.1.1.patch
Package in yarn.lock:
react-native-document-picker@^6.0.4:
version "6.1.1"
resolved "https://registry.yarnpkg.com/react-native-document-picker/-/react-native-document-picker-6.1.1.tgz#5ae72d489ea6d04f8325802570b1e24fc2c30a66"
integrity sha512-WcmPR/z+8dlPRqMCd+LwFXv9S/Q1gihf2lj/X2BVRxqQzQ+UEGo9mXjxcYB7mWKDkAqYS1MjdBcbfDycmTSs/A==
dependencies:
invariant "^2.2.4"
Error in CircleCI:

Worth to mention that other patches are applied successfully before this error
I also tried both suggestions in the error message
EDIT: After another attempt I managed to identify the modified line from the react-native-document-picker package provoking the failure. It's from its android/build.gradle file where I commented the line buildToolsVersion safeExtGet('DocumentPicker_buildToolsVersion', '29.0.2'). Commenting or removing this line repeatedly triggered the warning, and leaving it as is passed successfully
Patch when the line is removed:
diff --git a/node_modules/react-native-document-picker/android/build.gradle b/node_modules/react-native-document-picker/android/build.gradle
index 0d09fbf..5b45f21 100644
--- a/node_modules/react-native-document-picker/android/build.gradle
+++ b/node_modules/react-native-document-picker/android/build.gradle
@@ -2,7 +2,7 @@ buildscript {
if (project == rootProject) {
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
@@ -19,7 +19,6 @@ def safeExtGet(prop, fallback) {
android {
compileSdkVersion safeExtGet('DocumentPicker_compileSdkVersion', 29)
- buildToolsVersion safeExtGet('DocumentPicker_buildToolsVersion', '29.0.2')
defaultConfig {
minSdkVersion safeExtGet('DocumentPicker_minSdkVersion', 21)
targetSdkVersion safeExtGet('DocumentPicker_targetSdkVersion', 29)
@@ -49,7 +48,7 @@ repositories {
url("$rootDir/../node_modules/react-native/android")
}
google()
- jcenter()
+ mavenCentral()
}
dependencies {
Patch when I leave the line as is
diff --git a/node_modules/react-native-document-picker/android/build.gradle b/node_modules/react-native-document-picker/android/build.gradle
index 0d09fbf..d96b45f 100644
--- a/node_modules/react-native-document-picker/android/build.gradle
+++ b/node_modules/react-native-document-picker/android/build.gradle
@@ -2,7 +2,7 @@ buildscript {
if (project == rootProject) {
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
@@ -49,7 +49,7 @@ repositories {
url("$rootDir/../node_modules/react-native/android")
}
google()
- jcenter()
+ mavenCentral()
}
dependencies {
EDIT: After another attempt I managed to identify the modified line from the react-native-document-picker package provoking the failure. It's from its android/build.gradle file where I commented the line buildToolsVersion safeExtGet('DocumentPicker_buildToolsVersion', '29.0.2'). Commenting or removing this line repeatedly triggered the warning, and leaving it as is passed successfully
@SkipCat I'm seeing the same issue on netlify builds (see #375). The weird thing is that certain patches are able to apply without error whereas other patches fail. I haven't figured out which specific lines cause a failure.
solution: delete folder 'vue-pdf' npm install vue-pdf npm run postinstall success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
solution: delete folder 'vue-pdf' npm install vue-pdf npm run postinstall success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
package.json: "postinstall": "patch-package",