cweagans / composer-patches

Simple patches plugin for Composer
https://www.cweagans.net/project/composer-patches
BSD 3-Clause "New" or "Revised" License
1.53k stars 240 forks source link

error: patch failed, "patch does not apply" and 'Hunk #X FAILED (different line endings). #156

Closed positonic closed 6 years ago

positonic commented 7 years ago

I'm stuck right now. Patching was working previously, and I feel like I didn't change anything... though I could be wrong....

I'm getting this error when I run composer update...:

Extracting archive - Applying patches for wpackagist-plugin/postcode-shipping patches/post_codeShipping.patch (Add default param to method call) cd 'public/plugins/postcode-shipping' && git --git-dir=. apply --check '-p1' '/home/james/code/wordplate/app/patches/post_codeShipping.patch' error: patch failed: postcode_shipping.php:561

error: postcode_shipping.php: patch does not apply

cd 'public/plugins/postcode-shipping' && git --git-dir=. apply --check '-p0' '/home/james/code/wordplate/app/patches/post_codeShipping.patch' error: b/postcode_shipping.php: No such file or directory

cd 'public/plugins/postcode-shipping' && git --git-dir=. apply --check '-p2' '/home/james/code/wordplate/app/patches/post_codeShipping.patch' fatal: unable to find filename in patch at line 1

cd 'public/plugins/postcode-shipping' && git --git-dir=. apply --check '-p4' '/home/james/code/wordplate/app/patches/post_codeShipping.patch' fatal: unable to find filename in patch at line 1

patch '-p1' --no-backup-if-mismatch -d 'public/plugins/postcode-shipping' < '/home/james/code/wordplate/app/patches/post_codeShipping.patch' (Stripping trailing CRs from patch; use --binary to disable.)

patching file postcode_shipping.php

Hunk #1 FAILED at 346 (different line endings).

Hunk #2 FAILED at 561 (different line endings).

2 out of 2 hunks FAILED -- saving rejects to file postcode_shipping.php.rej

I'm guessing I can ignoreerror: patch failed: errors, as it's just looking in directories...?

I'm thinking that the actual problem is:

Hunk #1 FAILED at 346 (different line endings).

If so, how to I get around this?

I see:

(Stripping trailing CRs from patch; use --binary to disable.)

I see plenty of advice around the internets to run git apply with this:

-l or --ignore-white-space option

but not sure how to do this, with composer-patches, since this command is inside composer-patches core....

Any help gratefully appreciated :)

cweagans commented 7 years ago

Fix your patch or the dependency that you're changing. This plugin doesn't do anything to ignore failures on patches. That's by design.

pinich commented 6 years ago

patch -p1 < example.patch

worked for me

cweagans commented 6 years ago

Closing, as this is out of scope for the plugin to resolve as far as I can see.