patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

Random patch-package failures on CI

Open ottoo opened this issue 4 years ago • 4 comments

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.

ottoo avatar Nov 03 '20 21:11 ottoo

I'm seeing the same error on GitLab CI with iOS builds (works locally).

UPDATE Clearing runner caches seems to have fixed it.

joegoodall1 avatar Nov 25 '20 17:11 joegoodall1

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.

jehartzog avatar May 12 '21 18:05 jehartzog

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?

vasylnahuliak avatar Dec 14 '21 08:12 vasylnahuliak

fwiw when running --reverse it also fails

angelo-hub avatar Dec 08 '22 20:12 angelo-hub