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

D7: Error about not being able to apply patch on composer install #498

Closed
lukasz-zaroda opened this issue Jul 23, 2019 · 10 comments
Closed

Comments

@lukasz-zaroda
Copy link

First composer install works fine, but the consecutive ones give:

./composer.json has been updated
Gathering patches for root package.
Removing package cweagans/composer-patches so that it can be re-installed and re-patched.
  - Removing cweagans/composer-patches (1.6.5)
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing cweagans/composer-patches (1.6.6): Loading from cache
  - Applying patches for cweagans/composer-patches
    https://github.com/SebCorbin/composer-patches/commit/1cb9bacba51f8bba0c5f3f322c3bb61e4ceae974.patch (Call the preserve paths hooks)
   Could not apply patch! Skipping. The error was: Cannot apply patch https://github.com/SebCorbin/composer-patches/commit/1cb9bacba51f8bba0c5f3f322c3bb61e4ceae974.patch

Writing lock file
Generating autoload files
> DrupalProject\composer\ScriptHandler::createRequiredFiles
@normanlolx
Copy link
Collaborator

normanlolx commented Jul 24, 2019

You are applying this patch to the 1.6.6 tagged release of the package. But this patch needs to be applied to the 1.x branch of its repo. The code between both states is different, that's why it's not applying the patch. You need to require 1.x first:

composer require cweagans/composer-patches:1.x

Link to patch: cweagans/composer-patches#257

@lukasz-zaroda
Copy link
Author

lukasz-zaroda commented Jul 24, 2019

Well I'm not applying anything explicitly, it's just the default behavior after setting up a project. So I'm assuming that the composer.json has wrong cweagans/composer-patches reference.

@normanlolx
Copy link
Collaborator

normanlolx commented Jul 24, 2019

Hum, I cannot reproduce this. Neither with a fresh setup nor with requiring cweagans/composer-patches:1.6.5 or cweagans/composer-patches:1.6.6 explicitly.

What exactly you have done that the ./composer.json has been updated as the first line of your output is saying?

@lukasz-zaroda
Copy link
Author

Well in this case, it was probably just me trying 1.6.5 version before. This is the verbose output I just tried:

Gathering patches for root package.
Removing package cweagans/composer-patches so that it can be re-installed and re-patched.
  - Removing cweagans/composer-patches (1.6.6)
> pre-install-cmd: DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Dependency resolution completed in 0.001 seconds
Analyzed 106 packages to resolve dependencies
Analyzed 238 rules to resolve dependencies
Package operations: 1 install, 0 updates, 0 removals
Installs: cweagans/composer-patches:1.6.6
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
Found 1 patches for cweagans/composer-patches.
  - Installing cweagans/composer-patches (1.6.6): Loading from cache
 Extracting archive  - Applying patches for cweagans/composer-patches
    https://github.com/SebCorbin/composer-patches/commit/1cb9bacba51f8bba0c5f3f322c3bb61e4ceae974.patch (Call the preserve paths hooks)
patch '-p1' --no-backup-if-mismatch -d '/var/www/html/vendor/cweagans/composer-patches' < '/tmp/5d382288e9dd6.patch'
patch: unrecognized option: no-backup-if-mismatch

BusyBox v1.28.4 (2018-07-17 15:21:40 UTC) multi-call binary.

Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]

        -p,--strip N            Strip N leading components from file names
        -i,--input DIFF         Read DIFF instead of stdin
        -R,--reverse            Reverse patch
        -N,--forward            Ignore already applied patches
        -E,--remove-empty-files Remove output files if they become empty

patch '-p0' --no-backup-if-mismatch -d '/var/www/html/vendor/cweagans/composer-patches' < '/tmp/5d382288e9dd6.patch'
patch: unrecognized option: no-backup-if-mismatch

BusyBox v1.28.4 (2018-07-17 15:21:40 UTC) multi-call binary.

Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]

        -p,--strip N            Strip N leading components from file names
        -i,--input DIFF         Read DIFF instead of stdin
        -R,--reverse            Reverse patch
        -N,--forward            Ignore already applied patches
        -E,--remove-empty-files Remove output files if they become empty

patch '-p2' --no-backup-if-mismatch -d '/var/www/html/vendor/cweagans/composer-patches' < '/tmp/5d382288e9dd6.patch'
patch: unrecognized option: no-backup-if-mismatch

BusyBox v1.28.4 (2018-07-17 15:21:40 UTC) multi-call binary.

Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]

        -p,--strip N            Strip N leading components from file names
        -i,--input DIFF         Read DIFF instead of stdin
        -R,--reverse            Reverse patch
        -N,--forward            Ignore already applied patches
        -E,--remove-empty-files Remove output files if they become empty

patch '-p4' --no-backup-if-mismatch -d '/var/www/html/vendor/cweagans/composer-patches' < '/tmp/5d382288e9dd6.patch'
patch: unrecognized option: no-backup-if-mismatch

BusyBox v1.28.4 (2018-07-17 15:21:40 UTC) multi-call binary.

Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]

        -p,--strip N            Strip N leading components from file names
        -i,--input DIFF         Read DIFF instead of stdin
        -R,--reverse            Reverse patch
        -N,--forward            Ignore already applied patches
        -E,--remove-empty-files Remove output files if they become empty

   Could not apply patch! Skipping. The error was: Cannot apply patch https://github.com/SebCorbin/composer-patches/commit/1cb9bacba51f8bba0c5f3f322c3bb61e4ceae974.patch

Generating autoload files
> post-install-cmd: DrupalProject\composer\ScriptHandler::createRequiredFiles

@lukasz-zaroda
Copy link
Author

Actually it might be git related: cweagans/composer-patches#148 .

@normanlolx
Copy link
Collaborator

Oh yes, good catch. Seems likely. What's your Git version then?

@lukasz-zaroda
Copy link
Author

I think I figured it out, see this: cweagans/composer-patches#159 (comment) I'm running composer in Alpine docker container. I think we just have to wait for cweagans/composer-patches#184 merge unfortunately :( .

@lukasz-zaroda
Copy link
Author

I will try also to update my Alpine version and let you know, as it seems that it might fix it.

@normanlolx
Copy link
Collaborator

You can also try to apply the mentioned PR to your version of cweagans/composer-patches. Maybe they get through.

Just change https://github.com/cweagans/composer-patches/pull/184/files to https://github.com/cweagans/composer-patches/pull/184.patch to get the patch URL.

@lukasz-zaroda
Copy link
Author

lukasz-zaroda commented Jul 24, 2019

I can confirm that it works on alpine 3.10 assuming that patch package has been explicitly installed (only this seems to guarantee the newest, unaffected version), so that's good enough for me.

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

2 participants