-
-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better handling for cached 'node_modules' folder #37
Comments
Hey, thanks for the solid issue report! I see the problem, and so far I like the second solution you proposed. Not sure I understand exactly how the first would work, could you detail that for me? In the second case, would the |
Here's a snippet of our current CircleCI steps: - restore_cache:
key: node-modules-cache-{{ checksum "yarn.lock" }}
- run: yarn install
- run: yarn test # Run tests
- save_cache:
key: node-modules-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules Note the In the first proposed solution, we could change the cache key to something like:
Then the cache will miss and CI will rebuild In the second proposed solution, we could simply add a step to revert the patches before saving cache: - restore_cache:
key: node-modules-cache-{{ checksum "yarn.lock" }}
- run: yarn install
- run: yarn test # Run tests
- run: yarn patch-package revert # <-- Add this line
- save_cache:
key: node-modules-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules So the cache does not contains patches. |
Apologies for the delay in getting back to this. For the checksum thing, I see how that works now and it seems like a good solution to me, but I'm not sure that it makes sense for patch-package to provide as a feature, since it's specifically related to working around expressivity issues with CircleCI's cache configuration. It seems like it should be possible to find a solution within the circle build by generating the lock file before restoring the cache with a command like If that's not possible for some reason then the second solution is definitely doable. Without patch-package's help you could apply the patches in reverse using the unix |
Thanks for you reply. |
+1, same issue here with CircleCI. |
Hi peeps. I just published v5.1.0 of patch-package which has a |
I just ran into the exact same issue. Unfortunately I don't think I'm not sure there's any solution to this problem, but at the very least I hope we can improve the error message, so it's clear the patch failed because it's being applied to something that has already been modified. The patch could carry a hash of the original file, and then when the patch is applied, if the hash of the target file doesn't match the original, the patch would fail with an error along the lines of "target has unexpected hash". /cc @ds300 |
I was able to use |
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 patchednode_modules
folder is cached by CI.The issue
patch-package
and add it asprepare
script, as instructed by README.foo-bar
usingpatch-package foo-bar
. Commit the resultedpatches/foo-bar+X.X.X.patch
to repo.node_modules
folder and saves the result to cache.foo-bar
and regenerate patch file.node_modules
folder (which has incorporated previous version of the patch).node_modules
:Proposed solutions
Add a checksum file for the
patches
folder so we can easily check if patches has been changed before restoring cache from CI.Or, add a operation that can revert applied patches, such as
patch-package revert
. So we can revert the patches and save the cleannode_modules
folder to cache.The text was updated successfully, but these errors were encountered: