patch-package
patch-package copied to clipboard
Random patch-package failures on CI
I've tried the tips described in the readme and in one of the issues about creating a checksum of the patches
folder but to no luck, I still keep getting random failures from patch-package
on CircleCI. It's always the same package that fails, which is weird as well.
Any tips? I feel like I've tried everything, changing cache keys, trying to create a new patch file, the checksums..
The CircleCI config looks something like this with custom commands for loading/saving the cache
commands:
save_yarn_cache:
steps:
- save_cache:
key: &yarn_cache_key modules-v8-{{ checksum "yarn.lock" }}-{{ checksum "patches.hash" }}
paths:
- ~/.cache/yarn
- node_modules
yarn_install:
description: 'Restore cache, run yarn install, and save cache'
steps:
- run:
name: Create patched package checksum
command: md5sum patches/* > patches.hash
- restore_yarn_cache
- run:
name: Yarn Install
command: yarn install --frozen-lockfile
- save_yarn_cache
The error:
**ERROR** Failed to apply patch for package apollo-server-cache-redis at path
node_modules/apollo-server-cache-redis
This error was caused because patch-package cannot apply the following patch file:
patches/apollo-server-cache-redis+1.2.2.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 apollo-server-cache-redis
If that doesn't work, then it's a bug in patch-package, so please submit a bug
report. Thanks!
********github.com/ds300/patch-package/issues
error Command failed with exit code 1.
I'm seeing the same error on GitLab CI with iOS builds (works locally).
UPDATE Clearing runner caches seems to have fixed it.
We initially tried clearing the cache, but it quickly became painful as it would require going into CircleCI projects settings every time we patched a package. Additional, after we go to a cache number > 9, the CircleCI UI only shows the last digit, so we couldn't figure if it was at 10
or 20
or 200
. It ended up being a minor time sink.
The correct way to fix this is to apply npx patch-package --reverse
after the build is completed, but before the CircleCI cache is saved. See this discussion.
I recommend closing this issue, it was resolved for us by using the recommended solution.
I'm seeing the same error on GitLab CI with iOS builds (works locally).
UPDATE Clearing runner caches seems to have fixed it.
Could you please share your GitLab config for caching patches?
fwiw when running --reverse
it also fails