Skip to content
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

patch-package fails to apply changes when switching between branches #487

Open
fabioh8010 opened this issue Aug 22, 2023 · 0 comments
Open

Comments

@fabioh8010
Copy link

Case 1

Details

When switching between two branches that modifies a patch file, it will cause patch-package to always fail to apply the changes unless you delete node_modules.

Steps to reproduce

  1. Checkout a branch in your repo e.g. patch-package-1.
  2. Patch any library and commit the changes.
  3. Checkout a new branch based on this one e.g. patch-package-2.
  4. Patch the library again with new code and commit the changes.
  5. Switch between the branches and try to install dependencies, you will always get an error and the patch won’t be applied, unless you delete node_modules.
**ERROR** Failed to apply patch for package expensify-common at path
  
    node_modules/expensify-common

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

    patches/expensify-common+1.0.0.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 expensify-common
  
  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).

Case 2

Details

When switching from a branch that uses multi-patches feature in a library to a branch that does not in the same library, it will cause patch-package to always fail to apply the changes unless you delete node_modules.

Steps to reproduce

  1. Checkout a branch in your repo e.g. patch-package-1.
  2. Patch any library and commit the changes.
  3. Checkout a new branch based on this one e.g. patch-package-2.
  4. Patch the library again with new code using --append and commit the changes.
  5. Switch from patch-package-2 to patch-package-1 and try to install dependencies, you will always get an error and the patch won’t be applied, unless you delete node_modules (same error as Case 1).
  6. ⚠️ Switching from patch-package-1 to patch-package-2 won't cause this error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant