Skip to content

Better handling for cached 'node_modules' folder #37

Description

@leethree

Use case

We are using patch-package to fix some nasty dependency issues, it works great during development. But it sometimes causes CircleCI failures when a partially patched node_modules folder is cached by CI.

The issue

  1. Install patch-package and add it as prepare script, as instructed by README.
  2. Patch module foo-bar using patch-package foo-bar. Commit the resulted patches/foo-bar+X.X.X.patch to repo.
  3. When CI is run, CircleCI installs and patches the node_modules folder and saves the result to cache.
  4. Modify module foo-bar and regenerate patch file.
  5. CircleCI restores the previous cached node_modules folder (which has incorporated previous version of the patch).
  6. CircleCI fails when applying new patch to node_modules:
**ERROR** Failed to apply patch for package foo-bar

  This error was caused because Git cannot apply the following patch file:

    patches/foo-bar+X.X.X.patch

  This is usually caused by inconsistent whitespace in the patch file.

Proposed solutions

  1. Add a checksum file for the patches folder so we can easily check if patches has been changed before restoring cache from CI.

  2. Or, add a operation that can revert applied patches, such as patch-package revert. So we can revert the patches and save the clean node_modules folder to cache.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions