patch-package: Patch fails when created with v5

I get the following

This error was caused because Git cannot apply the following patch file:
    patches/react-scripts+1.0.17.patch
  This is usually caused by inconsistent whitespace in the patch file.

when CI tries to apply the patch that I created locally (OSX) with patch package 5. Downgrading to v3 resolves the issue.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 34 (14 by maintainers)

Most upvoted comments

@ds300 Maybe it’s because we are behind a private npm repo but we (both of us) only have the chance to install up to 5.1.1. Please, ignore this if we are the only ones reporting the problem.

Update: indeed it was, fixed now by our internal IT team =) Update2: v6.0.0-3 fixed the white space problem. Thanks!

Thanks for the detailed tips Liisa!

Update for this thread: Last night I made a lot of progress working on custom pure-TypeScript patch application. That will make these errors go away soon.

On Thu, 22 Mar 2018, 08:28 Liisa Duerig-Laitinen, notifications@github.com wrote:

I’ll keep that in mind next time around, thanks for the tip @dinvlad https://github.com/dinvlad.

I hope this issue finds a solution, this is an incredibly useful module. @ds300 https://github.com/ds300 , thanks so much for the great work on this!

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ds300/patch-package/issues/36#issuecomment-375216238, or mute the thread https://github.com/notifications/unsubscribe-auth/ABL1qQEqCsTc1vKjkVYxBta0f7MbmAKmks5tg2CXgaJpZM4Q-Wpv .

@ds300 I was having the same issue and for now, I can confirm the beta works 😃

I was also having this issue. I tried downgrading versions and all kinds of things which didn’t work. Removing the cache key and all the lines it included from travis.yml resolved the problem.

Here is the full list of steps I took before reaching this solution:

  • Created patch #1, created pull request, passed Travis tests, merged, patched changes visible on dev server.
  • The patched changes still had a bug, needed to create a new patch. Created patch #2, which included removing the lines added from patch #1 in addition to the changes I needed, rather than a fresh patch on a clean build. Travis tests failed with this error about whitespace.
  • Created patch #3 on a clean install, so the patch included only the lines that would be needed to have the proper fix on a clean build. Travis tests failed with this error about whitespace.
  • Deleted the patch entirely from the patches directory, created a new pull request which passed Travis tests, pull request merged. It did not seem that the undone changes were deployed, so I assumed that Travis must be starting from previous state of node_modules, rather than a fresh install.
  • Sent a new pull request for patch #3, just in case there was a cache or some other issue and the node_modules actually were installed from scratch. Travis failed, same error.
  • Removed the entire cache key from travis.yml, added this change to the previous pull request with patch #3. Voila, tests passed, pull request merged, and updated changes visible.
  • Added the cache key back to travis.yml and made a new pull request.

I think the step to delete the original patch may not have been necessary, but I am not entirely sure. Definitely the step for patch #2 was not useful. I hope any of this helps anyone else having this issue.