GitExcluder should not ignore .git directories that belong to packages installed by Composer

Created on 17 October 2022, over 1 year ago
Updated 26 January 2023, over 1 year ago

Problem/Motivation

I tried to update a website from 9.3.15 to 9.3.22 with automatic_updates module but the batch has crashed with this message:

In GitDownloader.php line 161:
The .git directory is missing from /var/www/tmp/.package_managere32fb233-9806-4363-9068-2727efa51a28/BnI-DQk5cSfYqad_EhNcNRK7PDJ-RvDdgeJU9dHyZhI/vendor/drupal/coder, see https://getcomposer.org/comm
it-deps for more information

The command "'/usr/local/bin/composer' '--working-dir=/var/www/tmp/.package_managere32fb233-9806-4363-9068-2727efa51a28/BnI-DQk5cSfYqad_EhNcNRK7PDJ-RvDdgeJU9dHyZhI' 'update' '--with-all-dependencies' 'drupal/core-composer-scaffold:9.3.22' 'drupal/core-project-message:9.3.22' 'drupal/core-recommended:9.3.22' 'drupal/core-vendor-hardening:9.3.22' 'drupal/core-dev:9.3.22'" failed.

( @see complete trace in screenshot)

The error is likely caused because drupal/core-dev is required and it require drupal/coder with --prefer-source

this can also happen even when you're using --prefer-dist: when you specify a version that can only be available through VCS such as dev-master: https://github.com/composer/composer/issues/6370.

Steps to reproduce

Run core update in bo from /admin/reports/updates/update

Proposed solution

There is caused because sometimes Composer needs the git directory, if `prefer-source` is used for instance.

  1. determine in cases Composer would need the git directory for a project. For instance if prefer-source maybe if it is VCS repository
  2. We should test requiring a package with --prefer-source and confirm we get this error if try to use auotmatic updates. Do we always ge the error or only if the package is being updated. We could also require module via --prefer source in the command and then try update it using Automatic Update Extensions.
  3. Update \Drupal\package_manager\PathExcluder\GitExcluder to not exlude git directories where composer needs them to work.

    It might be that it makes sense to never exclude a git directory that is at the `install_path` of the package known to composer. Because it is a composer managed directory and composer put a git directory there we can probably assume it needs it.

    see \Drupal\package_manager\ComposerUtility::getProjectForPackage() which gets the `install_path`.

    If

🐛 Bug report
Status

Fixed

Version

2.4

Component

Package Manager

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024