Problem/Motivation
When attempting to update a project from core 9.4.7 to core 9.5.0 (along with the drupal/core-composer-scaffold) plugin, I have issues where all of the Drupal folders remain in vendor/drupal. The files do properly get placed in my webroot (for me, that's docroot) but they do not get properly removed from vendor/drupal when install concludes. This is a super wonky problem, but a few things I've observed:
- Pinning to drupal/core-composer-scaffold 9.4.7 or removing it entirely resolves this problem. So, something in the (VERY MINOR) change that occurred https://github.com/drupal/core-composer-scaffold/compare/9.4.7...9.5.0 is likely to blame? Somehow?
- I didn't run into this on one project, but did on a second. At further examination, the project that "worked" has multiple custom repositories defined and if I add additional repositories to the broken project, it starts working too.
- There are no clear errors / problems, the only reason I discovered this was my includes for DRUPAL_ROOT started throwing PHP Fatals after the update
Steps to reproduce
1. Clone https://github.com/Drupal4Gov/drupal4gov.us
2. Run a composer install
3. check vendor/drupal (should be ok)
4. run composer update "drupal/core*" -W (should update to 9.5.x)
5. check vendor/drupal (will now contain core and all the contrib modules)
after the above, if you remove the core/core-composer-scaffold, nuke the vendor folder, and re-run the composer update it should be fine. if you re-add core-composer-scaffold but pin to 9.4.7, nuke the vendor directory, and re-run composer update it should be fine. there's something about the 9.5.0 version of this that is problematic.
Proposed resolution
Either roll back the code change in https://github.com/drupal/core-composer-scaffold/compare/9.4.7...9.5.0 or iterate on the proposed approach to address this edge case.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 3328893-16.diff | 1.1 KB | claudiu.cristea |
Issue fork drupal-3328893
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
mikemadison commentedComment #3
mikemadison commentedComment #4
effulgentsia commentedIf it's correct that that diff is the culprit, then #3283498: Scaffold ReplaceOp::copyScaffold() throws an error for empty files is the issue that introduced that, so linking it as the related issue.
I guess a way to debug this would be to change the
=== FALSEback to a looser falsy (e.g.,!()) check, and identify what is the case where a file is being written with 0 bytes, and why is treating that as an error condition (as 9.4.7 did) producing the desired result whereas treating it as an okay condition (as 9.5.0 does) produces this bug.Comment #5
mglamanChiming in: I was able to reproduce using the provided commands
Comment #6
mile23I wasn't able to repro. I had to set up under ddev, using PHP 8.0 because that's what the locked dependencies require.
Comment #7
mikemadison commentedFWIW I'm running composer 2.5.1 and running PHP 8.1 on my system.
Comment #8
mile23The code that would move the modules around would be
composer/installersoroomphinc/composer-installers-extenderplugins.Those plugins aren't explicitly included in https://github.com/Drupal4Gov/drupal4gov.us/blob/main/composer.json so maybe a newer version of some dependency doesn't include them either...? Some version that only loads when you're using PHP 8.1 but not 8.0?
Comment #9
reg commentedHaving had this same issue I went looking at the scaffolding documentation and this part got my attention:
Since it's simple to change a web servers root and I can easily change my web servers root to /web so is there any reason for scaffolding if I simply make my web root /web? That way if it's not working one can just disable it and I have no reason to be concerned about whether the structure matches 8.7 and earlier. As long as it installs and works the same I am fine with the structure and it certainly installs if I just change the web server's root to /web. However, I haven't extensively tested it working after installation as of yet.
Also, is there some reason why it wouldn't be fully managed by composer if left as is, i.e., scaffolding disabled?
Comment #10
mile23Here's what the scaffolding plugin does in a fresh install of core 10.0.0. This is extracted from a log of running
composer create-project drupal/recommended-project:These files are placed by the drupal/core configuration. Note that one of them is index.php. You might need that, and if you disable the scaffold plugin you won't get it. :-)
These files are placed in *either* the root of the project for the old-school vendor-in-docroot style installation (aka drupal/legacy-project) or the best-practice vendor-outside-docroot style (drupal/recommended-project).
The remaining file system requirements and best practices are handled by the composer/installers or oomphinc/composer-installers-extender plugins. That's how Drupal Core puts itself into web/core/ instead of vendor/drupal/, and puts modules in modules/contrib/ and so forth.
If you can configure your web server's docroot to be different from /www/html/, such as /www/html/web/, then the best practice is to: a) Configure the installers plugins to use that, and b) tell the scaffold to place the scaffolded files in your configured web-root. The easiest way to do that is to look at drupal/recommended-project and either copy it or use it as the template for your new site.
It's entirely unclear why this issue with vendor duplication is occurring, and again I can't repro it.
One thing that normally happens is: During early phases, everything is installed in vendor/. It isn't until the end that these items are moved out of vendor/ and into modules/contrib or whatever. It could be that there is something about the toolchains in use that error this out or somehow prevent it from happening.
Is this process expected to happen under an Acquia dev environment or something? I noticed that BLT and other Acquia tools are requirements, which is why I ask.
Comment #11
reg commented@Mile23: Thank you for that rundown and it confirms what I was thinking for the web root. One possibility, at least in my case, I know that index.php file is in /web and naturally put my web root to /web before ever running the site so maybe there's some permissions thing that can happen on some servers in that circumstance that allows the copying to doc root but not the subsequent removal from the sources inside /web.
I personally can't see how that can be but perhaps not everybody sets their web root to /web from the get go so that's a possibility for a cause in it's change of behavior and like someone above said it also seems to be specific to 9.5.0 (and I guess possibly above).
Comment #12
reg commentedIf your setup is such that you are not going to use scaffolding I think the most unobtrusive way to do so is just to run the line:
composer config allow-plugins.drupal/core-composer-scaffold falseThis should disable scaffolding but leave all the settings (other than disabling it) intact. I'm testing this now and will add more if I find out anything different.
Comment #13
claudiu.cristeaSame here but with different symptoms: The
web/coredirectory is polluted with non-Drupal packages fromvendor/Comment #14
claudiu.cristeaWhen I set the "drupal/core-composer-scaffold" plugin to false, everything looks good. Setting to Major as this blocks me to update to 9.5.x
Comment #15
claudiu.cristeaReverting https://github.com/drupal/core-composer-scaffold/compare/9.4.7...9.5.0 is fixing my issue. But how to satisfy this and also the source issue?
Comment #17
claudiu.cristeaThe MR if fixing my issue. Curious if it's resolving also the original report issue.
Posting as patch because of https://drupal.slack.com/archives/C51GNJG91/p1673438297534429
Comment #18
mikemadison commentedI imagine it does, I was pinning to the previous version of the scaffold which is effectively the same as the patch to revert the change made in 9.5.0.
Comment #19
claudiu.cristeaNo, sorry, in fact it doesn't solve my issue.
Comment #20
mile23It would be super-great if someone could provide repro steps... What environments is this happening under? Are there symlinks? If you remove all the plugins except the ones that come with core, does it do the right thing? If you update all your plugins to the latest stable, what happens? Etc.
Comment #21
smustgrave commentedAdditional info was requested in #20
For what it's worth when we upgraded all our 9.4 sites to 9.5 no one reported this issue.
Comment #22
mile23Based on #20 and #21.
Comment #24
pameeela commentedClosing this since there hasn't been any additional info provided after it was requested more than a year ago.