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

Strange behaviour with docker alpine containers #416

Closed
emembeka opened this issue Jul 22, 2022 · 3 comments
Closed

Strange behaviour with docker alpine containers #416

emembeka opened this issue Jul 22, 2022 · 3 comments

Comments

@emembeka
Copy link

I'm trying to apply a valid patch for drupal core but it always fails when I call composer install,

bash-5.1$ rm -rf web/core/
bash-5.1$ composer install
Gathering patches for root package.
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 1 install, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing drupal/core (9.4.3): Extracting archive
  - Applying patches for drupal/core
    https://www.drupal.org/files/issues/2020-07-18/2086125-71.patch (https://www.drupal.org/project/drupal/issues/2086125)
   Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-07-18/2086125-71.patch

In Patches.php line 326:
                                                                                                                                              
  Cannot apply patch https://www.drupal.org/project/drupal/issues/2086125 (https://www.drupal.org/files/issues/2020-07-18/2086125-71.patch)!  

The same patch (with the same composer.json, same php-version) applies when I require the core with --prefer-source

bash-5.1$ composer require drupal/core --prefer-source
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^9.4 for drupal/core
./composer.json has been updated
Running composer update drupal/core
Gathering patches for root package.
Removing package drupal/core so that it can be re-installed and re-patched.
  - Removing drupal/core (9.4.3)
Deleting web/core - deleted
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Syncing drupal/core (9.4.3) into cache
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing drupal/core (9.4.3): Cloning 7b1a403c09 from cache
  - Applying patches for drupal/core
    https://www.drupal.org/files/issues/2020-07-18/2086125-71.patch (https://www.drupal.org/project/drupal/issues/2086125)
                                                                                                                                              

This happens inside an alpine 3.16 container with php 7.4 & php 8.0
Outside the container on my ubuntu workstation composer installis working as expected

$ rm -rf web/core
$ composer install
Gathering patches for root package.
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 1 install, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing drupal/core (9.4.3): Extracting archive
  - Applying patches for drupal/core
    https://www.drupal.org/files/issues/2020-07-18/2086125-71.patch (https://www.drupal.org/project/drupal/issues/2086125)

I think there is nothin special inside the compser.json:

  "require": {
    "composer/installers": "^1.0",
    "cweagans/composer-patches": "^1.7",
...
    "drupal/core": "^9.4",
    "drupal/core-recommended": "^9.4",
...
  },
  "config": {
    "sort-packages": true,
    "discard-changes": true,
    "bin-dir": "bin/",
    "allow-plugins": {
      "composer/installers": true,
      "cweagans/composer-patches": true,
      "dealerdirect/phpcodesniffer-composer-installer": true
    }
  },
...
    "patches": {
      "drupal/core": {
        "https://www.drupal.org/project/drupal/issues/2086125": "https://www.drupal.org/files/issues/2020-07-18/2086125-71.patch"
      },
  }

My best guess is that there are difference in php-libraries or php.ini that results in that behaviour, but I have no idea which settings should be changed, can anyone push me into the right direction?

@cweagans
Copy link
Owner

Extremely likely that patch is not installed. You can verify with composer -vvv install

@emembeka
Copy link
Author

Ha! that's it! Thank you for the helpful comment :-D

Downloading https://www.drupal.org/files/issues/2020-07-18/2086125-71.patch
patch '-p1' --no-backup-if-mismatch -d 'web/core' < '/tmp/62db17bf651fb.patch'
Executing command (CWD): patch '-p1' --no-backup-if-mismatch -d 'web/core' < '/tmp/62db17bf651fb.patch'
sh: patch: not found

And this explains why it is working with --prefer-source, as git is used to patch the files.

Doesn't it make sence to check the existance of patchan give a better error message to the user?

@cweagans
Copy link
Owner

Yep. #400 :)

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

Successfully merging a pull request may close this issue.

2 participants