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
Note: 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.
- determine in cases Composer would need the git directory for a project. For instance if prefer-source maybe if it is VCS repository
- 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.
- 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
| Comment | File | Size | Author |
|---|---|---|---|
| error.png | 670.19 KB | daisyleroy |
Issue fork automatic_updates-3315834
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
tedbowComment #3
kunal.sachdev commentedComment #5
tedbowWe need to update the tests.
Right we test 2 .git directories are ignore we need to test that .git won't be ignore if we find a a matching
install_pathComment #6
kunal.sachdev commentedComment #7
tedbowComment #8
tedbow@kunal.sachdev thanks. I think this is close. The
realpath+ VFS problem is trickyComment #9
kunal.sachdev commentedComment #10
tedbowA couple changes needed and a small change to how to test
realpath()based on our scrum discussion.Pretty close though
Comment #11
kunal.sachdev commentedComment #12
tedbow@kunal.sachdev thanks looks good. I made 1 comment change. will merge when green
Comment #13
phenaproximaComment #14
phenaproximaI think this looks pretty good and I agree with @tedbow's RTBC, but I'd like to make a few phrasing changes (and comment additions) to make sure this is well-documented. Self-assigning to handle that.
Comment #15
phenaproximaI think there may be another flaw here -- what if, in the stage directory, a package is added which is installed from source? We should be sure we're not excluding that from being copied back into the active directory.
Comment #16
tedbowComment #17
tedbowComment #18
wim leers@phenaproxima, can you please confirm that in #15 you actually wanted to see this test coverage: https://git.drupalcode.org/project/automatic_updates/-/merge_requests/54... ? 🙏
Comment #19
wim leersAlright, yay, this is actionable again!
Comment #20
tedbowComment #21
omkar.podey commentedComment #22
omkar.podey commentedComment #23
omkar.podey commentedComment #24
omkar.podey commentedNeed some clarity on what exactly indirect dependencies mean are they just dependencies of dependencies ? and where do these indirect dependencies live exactly just as other contrib modules?
Comment #25
omkar.podey commentedComment #26
wim leersSee #15 — it's referring to a composer package that was installed because another composer package was installed.
For example: you want to install
foo/foo. Butfoo/foodepends onfoo/core. ⇒ We should verify thatfoo/coreis also processed correctly.Comment #27
omkar.podey commented\Drupal\package_manager_bypass\Committersince it does not respect the exculsions sent from\Drupal\package_manager\PathExcluder\GitExcluderand copies everything from stage to active directory.\Drupal\Tests\package_manager\Kernel\PathExcluder\GitExcluderTest::testGitDirectoriesExcludedActiveworks as expected and the validator seems to work as intended while copying directories from active to stage directory.Comment #28
omkar.podey commentedNot asserting using invocation args in
testGitDirectoriesExcludedStageas there won't be any reliable assertion for a new package being added in the stage.Comment #29
omkar.podey commentedCreated #3328600: Update a build test for integration testing and be able to verify directory changes in stage. for build test change.
Comment #30
omkar.podey commentedComment #31
wim leers12 remarks on the MR, a few questions for @tedbow, but mostly clean-up that's necessary before I can RTBC this for @tedbow to review 🤓
Comment #32
omkar.podey commentedComment #33
wim leersI did a very thorough review of this issue that keeps surprising us! 🤓
14 remarks. Some of them nits about formatting/naming/etc. But also some genuine code clarity/maintainability remarks, and a few fairly fundamental questions.
So close!
Comment #34
omkar.podey commentedPostponed on #3330139: Harden PathExclusionsTrait::excludeInProjectRoot() for paths outside of project root.
Comment #35
omkar.podey commentedCreated #3330140: Update StatusCheckTrait::runStatusCheck() to reorder/avoid dispatching CollectIgnoredPathsEvent earlier than StatusCheckEvent
Comment #36
omkar.podey commentedComment #37
tedbow#3330139: Harden PathExclusionsTrait::excludeInProjectRoot() for paths outside of project root. fixed
Comment #38
wim leersYep — adjusting title 🤓
Comment #39
omkar.podey commentedRevisiting #3330140: Update StatusCheckTrait::runStatusCheck() to reorder/avoid dispatching CollectIgnoredPathsEvent earlier than StatusCheckEvent I think it needs to happen first as we will always hit the excluder first and don't have proper validation for a missing composer file/(an issue while computing ignored_paths) in it.
Comment #40
wim leersReflecting #39.
Comment #41
tedbow#3330140: Update StatusCheckTrait::runStatusCheck() to reorder/avoid dispatching CollectIgnoredPathsEvent earlier than StatusCheckEvent fixed
Comment #42
omkar.podey commentedComment #43
wim leersI know I said we could just include the case we missed in #3330140: Update StatusCheckTrait::runStatusCheck() to reorder/avoid dispatching CollectIgnoredPathsEvent earlier than StatusCheckEvent in this MR. But I noticed there's another case. So we'll need to handle that first.
Please move https://git.drupalcode.org/project/automatic_updates/-/merge_requests/54... into a separate MR and handle + test the extra case there. That can then land swiftly.
It'll keep the scope here simpler.
To avoid such a late discovery in the future, I suggest testing the stack-of-MRs (or patches) locally to verify that tests are passing. Or just create a patch (or MR) that represents the full stack of changes, then we'd have known days ago that not all cases were handled in #3330140!
Comment #44
omkar.podey commentedJust testing if this passes and then moving validation and tests to a separate MR.
Comment #45
omkar.podey commentedcreated #3334054: Add error handling for \Drupal\package_manager\Stage::getIgnoredPaths() and postponed on it.
Comment #46
omkar.podey commentedSo the thing is we can't really test our changes in #3334054: Add error handling for \Drupal\package_manager\Stage::getIgnoredPaths() because we don't have an excluder that fails on a call to the composer, basically we need the new git excluder for that so I think we should close that issue and add the validation in this issue itself. (The validation and test for it is already pushed up in the MR of the current issue.)
Comment #47
omkar.podey commentedComment #48
omkar.podey commentedComment #49
omkar.podey commentedComment #50
wim leers#46: that seems reasonable! Thank you for giving it a try! 😊🙏
@tedbow: see #3334054-4: Add error handling for \Drupal\package_manager\Stage::getIgnoredPaths().
Also, I have one more significant concern, for which I only just now discovered the potentially superior way to do it, thanks to working on #3331168: Limit trusted Composer plugins to a known list, allow user to add more. I'll let @tedbow decide though. @tedbow, see the MR, the mention of
\Composer\Package\Package::getDistType().Comment #51
tedbowI pushed up a commit to go with my MR comment but it will still need tests.
Comment #52
tedbowComment #53
omkar.podey commentedComment #54
tedbow@omkar.podey thanks for adding the new test but I think there is problem
I checked about the previous version of
package_manager/src/PathExcluder/GitExcluder.phpbefore my changeand ran your new test
\Drupal\Tests\package_manager\Kernel\PathExcluder\GitExcluderTest::testGitDirectoriesExcludedIsDirand it still passed.so this either means
scanStagewas actually not problemI haven't looked into enough to know yet.
Comment #55
wim leersI just discovered this can also happen even when you're using
--prefer-dist: when you specify a version that can only be available through VCS such asdev-master: https://github.com/composer/composer/issues/6370.Comment #56
wim leers@tedbow I'm especially curious about your thoughts on my lengthy research comment at https://git.drupalcode.org/project/automatic_updates/-/merge_requests/54... — IMHO we should open a Normal Postponed Task tagged
core-post-mvptitled . I'll do that if you agree after reading my comment 🤓Comment #57
omkar.podey commentedI also thought about the situation when (which might be obvious for everyone)
Comment #58
omkar.podey commentedI reopened #3334054: Add error handling for \Drupal\package_manager\Stage::getIgnoredPaths() and copied over whatever can be independently committed (without removing stuff from this MR for now), i still need to look at fixtures, But some tests related to the error handling of
\Drupal\package_manager\Stage::getIgnoredPathshave to be merged with the current MR.Comment #59
omkar.podey commentedpackage_manager/tests/src/Kernel/ComposerJsonExistsValidatorTest.phpComment #60
omkar.podey commentedComment #61
wim leersThanks for #59! 👍 That did definitely pre-emptively answer a few review questions 😄 Confirmed that reverting.
5 remarks on the MR, all around clarity. But this is definitely in the very final stretch! 👏
Comment #62
omkar.podey commentedComment #63
wim leersManually did
phpcslocally, all green 👍The follow-up I requested in #56 was created: #3334994: Add new InstalledPackagesList which does not rely on Composer API to get package info.
Comment #64
tedbowNeeds work
See question I put on the MR about the need for the new fixture
We just put a lot of effort into getting rid of most fixture folders so I want make sure we need this one.
Comment #65
omkar.podey commentedI agree, we can definitely create
addDotGitFolderComment #66
omkar.podey commentedcreated #3335802: Add addDotGitFolder functionality to \Drupal\fixture_manipulator\FixtureManipulator
Comment #67
wim leersI like it! 😄
Postponing on #3335802: Add addDotGitFolder functionality to \Drupal\fixture_manipulator\FixtureManipulator.
Comment #68
wim leersThis blocks #3334552: Ensure that intentionally failed test stage directories are deleted after tests complete, so tagging.
Comment #69
omkar.podey commentedIf the test above passes it proves the compatibility with #3335802: Add addDotGitFolder functionality to \Drupal\fixture_manipulator\FixtureManipulator
Comment #70
tedbowfixed #3335802: Add addDotGitFolder functionality to \Drupal\fixture_manipulator\FixtureManipulator
Comment #71
wim leersI'll get this across the finish line while @omkar.podey is on PTO.
First,
git merge origin/8.x-2.x…Comment #72
wim leersSince #71:
LockFileValidator::stopPropagation()additions which seem to be obsolete now.StagedDBUpdateValidatorTestchange because that seems to be obsolete too nowThat took this MR down from 13 changed files to a mere 3!
Comment #73
wim leersphpcspasses locally BTW 👍Comment #75
tedbowThanks everyone! A lot of work but a big win we don't message with git folder managed by Composer!