Closed tobias-kuendig closed 3 years ago
@tobias-kuendig We really haven't done any testing beyond the things that composer test
does in this repo to test the new ^2.0 api compatibility. If you have some more active way of testing things for your common use cases and could report on your findings here that would be greatly appreciated.
Glad to hear it @bd808! @tobias-kuendig could you test this out in October by changing the dependency to wikimedia/composer-merge-plugin: dev-composer20
and ensuring that everything October uses still functions normally in a composer 2.0 environment?
Not quite there yet!
$ php composer.phar --version
Composer version 2.0-dev (2.0-dev+a7ad186c89a597239536586b6fd09ac5df154869) 2020-04-09 15:12:35
Using October's composer.json with a few October plugins installed locally so the merge-plugin has something to merge.
The following error is fixed by #182
- Installing wikimedia/composer-merge-plugin (dev-composer20 7274d02): Extracting archive
PHP Fatal error: Uncaught Error: Undefined class constant 'PRE_DEPENDENCIES_SOLVING' in <dir>/vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php:159
Stack trace:
#0 phar://<dir>/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(397): Wikimedia\Composer\MergePlugin::getSubscribedEvents()
#1 phar://<dir>/composer.phar/src/Composer/Plugin/PluginManager.php(305): Composer\EventDispatcher\EventDispatcher->addSubscriber(Object(Wikimedia\Composer\MergePlugin))
#2 phar://<dir>/composer.phar/src/Composer/Plugin/PluginManager.php(206): Composer\Plugin\PluginManager->addPlugin(Object(Wikimedia\Composer\MergePlugin))
#3 phar://<dir>/composer.phar/src/Composer/Installer/PluginInstaller.php(70): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage), true)
#4 phar://<dir>/composer.phar/src/Composer/Installer/InstallationManager.php(299): Composer\Installer\Plugin in <dir>/vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php on line 159
The installation of October's modules are failing now:
- Installing october/backend (dev-master d0232da): Extracting archive
Install of october/backend failed
- Installing october/cms (dev-master 1a8e565): Extracting archive
Install of october/cms failed
- Installing october/system (dev-master 8204f6c): Extracting archive
Install of october/system failed
// ...
[RuntimeException]
Expected empty path to extract october/backend-dev-master into but directory exists: modules/backend
Exception trace:
() at phar://<dir>/composer.phar/src/Composer/Downloader/ArchiveDownloader.php:43
Composer\Downloader\ArchiveDownloader->install() at phar://<dir>/composer.phar/src/Composer/Downloader/DownloadManager.php:270
Composer\Downloader\DownloadManager->install() at phar://<dir>/composer.phar/src/Composer/Installer/LibraryInstaller.php:230
Composer\Installer\LibraryInstaller->installCode() at phar://<dir>/composer.phar/src/Composer/Installer/LibraryInstaller.php:134
Composer\Installer\LibraryInstaller->install() at phar://<dir>/composer.phar/src/Composer/Installer/InstallationManager.php:299
Composer\Installer\InstallationManager->install() at phar://<dir>/composer.phar/src/Composer/Installer/InstallationManager.php:244
Composer\Installer\InstallationManager->Composer\Installer\{closure}() at n/a:n/a
call_user_func() at phar://<dir>/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php:20
React\Promise\FulfilledPromise->then() at phar://<dir>/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php:34
React\Promise\Deferred->then() at phar://<dir>/composer.phar/vendor/react/promise/src/React/Promise/Promise.php:26
React\Promise\Promise->then() at phar://<dir>/composer.phar/src/Composer/Installer/InstallationManager.php:245
Composer\Installer\InstallationManager->execute() at phar://<dir>/composer.phar/src/Composer/Installer.php:677
Composer\Installer->doInstall() at phar://<dir>/composer.phar/src/Composer/Installer.php:523
Composer\Installer->doUpdate() at phar://<dir>/composer.phar/src/Composer/Installer.php:242
Composer\Installer->run() at phar://<dir>/composer.phar/src/Composer/Command/InstallCommand.php:119
Composer\Command\InstallCommand->execute() at phar://<dir>/composer.phar/vendor/symfony/console/Command/Command.php:245
Symfony\Component\Console\Command\Command->run() at phar://<dir>/composer.phar/vendor/symfony/console/Application.php:835
Symfony\Component\Console\Application->doRunCommand() at phar://<dir>/composer.phar/vendor/symfony/console/Application.php:185
Symfony\Component\Console\Application->doRun() at phar://<dir>/composer.phar/src/Composer/Console/Application.php:287
Composer\Console\Application->doRun() at phar://<dir>/composer.phar/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at phar://<dir>/composer.phar/src/Composer/Console/Application.php:113
Composer\Console\Application->run() at phar://<dir>/composer.phar/bin/composer:61
require() at <dir>/composer.phar:25
Looks like the installation now fails if the target directory is not empty. This check was recently added:
https://github.com/composer/composer/commit/73251691a0be65440c722461cb38f8574cea0c25
I guess this not a problem that concerns the merge-plugin, though.
Removing the modules
folder and running composer install again brings another error to light:
> init: Wikimedia\Composer\MergePlugin_composer_tmp0->onInit
[merge-plugin] Loading plugins/october/demo/composer.json...
[merge-plugin] Deferring duplicate php
[merge-plugin] Merging composer/installers
[merge-plugin] Loading plugins/offline/responsiveimages/composer.json...
[merge-plugin] Deferring duplicate php
[merge-plugin] Deferring duplicate composer/installers
[merge-plugin] Merging psr/log
[merge-plugin] Merging ext-dom
[merge-plugin] Merging rosell-dk/webp-convert
Reading ./composer.lock
> pre-install-cmd: Wikimedia\Composer\MergePlugin_composer_tmp0->onInstallUpdateOrDump
[merge-plugin] Already merged plugins/october/demo/composer.json completely
[merge-plugin] Already merged plugins/offline/responsiveimages/composer.json completely
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Reading ./composer.lock
Generating rules
Resolving dependencies through SAT
Looking at all rules.
Dependency resolution completed in 0.001 seconds
> pre-operations-exec: Wikimedia\Composer\MergePlugin_composer_tmp0->onDependencySolve
PHP Fatal error: Uncaught Error: Call to undefined method Composer\Installer\InstallerEvent::getRequest() in phar://<dir>/composer.phar/src/Composer/Plugin/PluginManager.php(195) : eval()'d code:302
Stack trace:
#0 [internal function]: Wikimedia\Composer\MergePlugin_composer_tmp0->onDependencySolve(Object(Composer\Installer\InstallerEvent))
#1 phar://<dir>/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(164): call_user_func(Array, Object(Composer\Installer\InstallerEvent))
#2 phar://<dir>/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(132): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Installer\InstallerEvent))
#3 phar://<dir>/composer.phar/src/Composer/Installer.php(638): Composer\EventDispatcher\EventDispatcher->dispatchInstallerEvent('pre-operations-...', true, true, Object(Composer\DependencyResolver\LocalRepoTransaction))
#4 phar://<dir>/composer.phar/src/Composer in phar://<dir>/composer.phar/src/Composer/Plugin/PluginManager.php(195) : eval()'d code on line 302
Fatal error: Uncaught Error: Call to undefined method Composer\Installer\InstallerEvent::getRequest() in phar://<dir>/composer.phar/src/Composer/Plugin/PluginManager.php(195) : eval()'d code:302
Stack trace:
#0 [internal function]: Wikimedia\Composer\MergePlugin_composer_tmp0->onDependencySolve(Object(Composer\Installer\InstallerEvent))
#1 phar://<dir>/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(164): call_user_func(Array, Object(Composer\Installer\InstallerEvent))
#2 phar://<dir>/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(132): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Installer\InstallerEvent))
#3 phar://<dir>/composer.phar/src/Composer/Installer.php(638): Composer\EventDispatcher\EventDispatcher->dispatchInstallerEvent('pre-operations-...', true, true, Object(Composer\DependencyResolver\LocalRepoTransaction))
#4 phar://<dir>/composer.phar/src/Composer in phar://<dir>/composer.phar/src/Composer/Plugin/PluginManager.php(195) : eval()'d code on line 302
The required request
property (and the getRequest
method) are no longer available:
https://github.com/composer/composer/commit/d52ce3c37fdfd78baa86fc20019f0b47f6d5eb92#diff-97f8c7e9c3a659cc5e166734b7ab8987
This was too deep into the Composer internals for me to provide a quick fix!
It seems like composer 2.0 is right around the corner. Downloading
https://getcomposer.org/composer.phar
already gives you a 2.0 build.
It should be noted that's "latest snapshot" not "latest stable" ;)
We hit the same issue trying out this branch:
Fatal error: Uncaught Error: Undefined class constant 'PRE_DEPENDENCIES_SOLVING' in vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php:159
We hit the same issue trying out this branch:
Fatal error: Uncaught Error: Undefined class constant 'PRE_DEPENDENCIES_SOLVING' in vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php:159
Using what versions?
https://github.com/wikimedia/composer-merge-plugin/blob/composer20/src/MergePlugin.php#L154-L160
PRE_OPERATIONS_EXEC is new in 2.0, so it sounds like it isn't found in your version, hence falling back to the 1.0 constant which doesn't exist in 2.0...
The dev-composer20
branch here together with composer 2.0.0-alpha1
Maybe it should be
$installerStartEvent = '';
if (defined('InstallerEvents::PRE_OPERATIONS_EXEC')) {
// composer-plugin-api ^2.0
$installerStartEvent = InstallerEvents::PRE_OPERATIONS_EXEC;
} elseif (defined('InstallerEvents::PRE_DEPENDENCIES_SOLVING')) {
// composer-plugin-api ^1.0
$installerStartEvent = InstallerEvents::PRE_DEPENDENCIES_SOLVING;
}
@tobias-kuendig Your PR works fine, thank you I added up my recommended change in https://github.com/wikimedia/composer-merge-plugin/pull/187 for us to merge, if that is OK with you.
It only fixes the constant issue, though We still also run into
PHP Fatal error: Uncaught Error: Call to undefined method Composer\Installer\InstallerEvent::getRequest() in /project/vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php:302
The Installer Event methods are only:
array(11) {
[0]=>
string(11) "__construct"
[1]=>
string(11) "getComposer"
[2]=>
string(5) "getIO"
[3]=>
string(9) "isDevMode"
[4]=>
string(21) "isExecutingOperations"
[5]=>
string(14) "getTransaction"
[6]=>
string(7) "getName"
[7]=>
string(12) "getArguments"
[8]=>
string(8) "getFlags"
[9]=>
string(20) "isPropagationStopped"
[10]=>
string(15) "stopPropagation"
}
Latest stable version of Composer is now officially 2.0 and I'm still encountering issues, even with the composer20
version.
Fatal error: Uncaught Error: Undefined class constant 'PRE_DEPENDENCIES_SOLVING' in vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php:159
What are the plans to fix this and can I do anything to help?
@lucasvdh Can you try #189?
The composer20 branch has not been updated since March. The undefined PRE_DEPENDENCIES_SOLVING
error requires #187 to fix a constant lookup. Even then, as noted previously, there is an additional error. This all has to do with the architectural differences between Composer v1 and v2.
That's where my PR comes in with an alternative to how extra packages are merged.
I've been spending quite a bit of time, in the last three months, researching Composer v2 and working on support for a few plugins.
Please, keep working on this issue. I need it to my project works fine on C2.
I need it to my project works fine on C2.
You are not alone :wink:: a lot of projects use this composer-merge-plugin, and all of them are forced to use version 1 of composer.
Or remove it again :) As we did.
Or remove it again :) As we did.
Is there any alternative package?
A colleague was working on that for us: https://github.com/spryker/composer-merge-plugin But that is specific to our use case. You might want to do sth similar then, just fork this, fix up the name and release a tag on it.
Did you guys try https://github.com/wikimedia/composer-merge-plugin/pull/189 ?
Did you guys try #189 ?
It seems to work (at least with concrete5)
Hello, I made an adjustment that solves the definition of constant. I did some tests here on top of the OctoberCMS project and everything went well (:
Hello, Do you have an update? Composer 2 is now officially released
I believe if you follow https://github.com/wikimedia/composer-merge-plugin/pull/189#issuecomment-719514950 then you can test this out in your project (with composer 2).
Someone made a working version here https://github.com/TopFloorTech/composer-merge-plugin/tree/composer-2-fix
Someone made a working version here https://github.com/TopFloorTech/composer-merge-plugin/tree/composer-2-fix
That fork simply merged #189 without additional changes (comparison).
composer having problem with this dependency:
Problem 1
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
composer having problem with this dependency:
Problem 1
- wikimedia/composer-merge-plugin[v1.4.0, ..., v1.4.1] require composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
- Root composer.json requires wikimedia/composer-merge-plugin ^1.4 -> satisfiable by wikimedia/composer-merge-plugin[v1.4.0, v1.4.1].
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
Have you read the thread? ;)
You can help by testing https://github.com/wikimedia/composer-merge-plugin/pull/189
composer having problem with this dependency:
Problem 1
wikimedia/composer-merge-plugin[v1.4.0, ..., v1.4.1] require composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
Root composer.json requires wikimedia/composer-merge-plugin ^1.4 -> satisfiable by wikimedia/composer-merge-plugin[v1.4.0, v1.4.1].
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
Have you read the thread? ;)
You can help by testing https://github.com/wikimedia/composer-merge-plugin/pull/189
I can confirm this works for my October CMS projects
This works for Apiato as well. Thank you,
Failed today trying to install in Drupal 9.1 `Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals
Fatal error: Uncaught Error: Undefined class constant 'PRE_DEPENDENCIES_SOLVING' in /home/stelnews/public_html/vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php:159 Stack trace:
Failed today trying to install in Drupal 9.1 `Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals
* Locking wikimedia/composer-merge-plugin (dev-composer20 [7274d02](https://github.com/wikimedia/composer-merge-plugin/commit/7274d0238193f52c429015865fe83cde71f56347)) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 0 removals * Syncing wikimedia/composer-merge-plugin (dev-composer20 [7274d02](https://github.com/wikimedia/composer-merge-plugin/commit/7274d0238193f52c429015865fe83cde71f56347)) into cache * Installing wikimedia/composer-merge-plugin (dev-composer20 [7274d02](https://github.com/wikimedia/composer-merge-plugin/commit/7274d0238193f52c429015865fe83cde71f56347)): Cloning [7274d02](https://github.com/wikimedia/composer-merge-plugin/commit/7274d0238193f52c429015865fe83cde71f56347) from cache
Fatal error: Uncaught Error: Undefined class constant 'PRE_DEPENDENCIES_SOLVING' in /home/stelnews/public_html/vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php:159 Stack trace:
0 phar:///home/stelnews/public_html/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(363): Wikimedia\Composer\MergePlugin::getSubscribedEvents()
1 phar:///home/stelnews/public_html/composer.phar/src/Composer/Plugin/PluginManager.php(322): Composer\EventDispatcher\EventDispatcher->addSubscriber(Object(Wikimedia\Composer\MergePlugin))
2 phar:///home/stelnews/public_html/composer.phar/src/Composer/Plugin/PluginManager.php(223): Composer\Plugin\PluginManager->addPlugin(Object(Wikimedia\Composer\MergePlugin), false)
3 phar:///home/stelnews/public_html/composer.phar/src/Composer/Installer/PluginInstaller.php(76): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage), true)
4 [internal function]: Composer\Installer\PluginInstaller->Composer\Installer{closure}(NULL)
5 phar:///home/stelnews/pu in /home/stelnews/public_html/vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php on line 159`
Have you read the thread? ;)
You can help by testing #189
Why its taking ages to get this issue fixed on the master branch, many forks have fixed the issues, and not sure what is the author of the plugin is waiting for!
Why its taking ages to get this issue fixed on the master branch, many forks have fixed the issues, and not sure what is the author of the plugin is waiting for!
See #189. There's still some issues and edge cases that need resolving.
Why are you so desperate to use Composer 2.0?
many forks have fixed the issues
Can you share with us these many forks? I'm the primary contributor of #189 and I'm curious about any other solutions out there that have not been opened as a pull request.
@mcaskill he's probably just talking about the local forks of your fix that some projects are using (i.e. OctoberCMS is using a fork of your package just in case any future commits to your branch stop working)
@reedy Personally, I'm not "desperate" but I do feel some urgency in getting things fixed. There is a strong push from the composer team to update and lots of tools are moving their defaults to composer 2 meaning there's more and more workarounds to stay on a legacy branch. I expect that house of cards to start falling apart to the point where some need update suddenly breaks and I'm forced to to a huge refactor either away from this or away from something else. Likely in a hurry because Murphy. So I'm definitely trying to keep any eye on and help forward things blocking a move to composer 2.
Unfortunately, I haven't been able to wrap my head around how to solve outstanding issue with the related PR yet :(
We've basically just put "composer-plugin-api": "^1.1",
into our composer.json for now. That's enough to stop things even running on composer 2.0
Unfortunately, I haven't been able to wrap my head around how to solve outstanding issue with the related PR yet :(
Which is part of the problem. It's not a trivial fix, unfortunately.
This is a working copy
Why its taking ages to get this issue fixed on the master branch, many forks have fixed the issues, and not sure what is the author of the plugin is waiting for!
Composer 1 is becoming so slow and its taking ~ 2GB of php memory
https://github.com/laraship/composer-merge-plugin works for me and I was able to composer my project in 128MB memory :)
This is a working copy
This is another fork that simply merges #189 without additional changes.
Any chance to see composer 2 compability soon?
I'm using following requirement for now:
"require": {
"wikimedia/composer-merge-plugin": "dev-feature/composer-v2 as 1.5.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mcaskill/composer-merge-plugin"
}
]
Thank you @afbora! That helped me to install Drupal webform's third party libraries!
Afbora, Where do I put that code?
@jimrome Place it in your project's root composer.json
. You will need to merge those entries into any existing require
and repositories
sections.
That worked! Thanks.
Does it still working?
"require": { "wikimedia/composer-merge-plugin": "dev-feature/composer-v2 as 1.5.0" }, "repositories": [ { "type": "vcs", "url": "https://github.com/mcaskill/composer-merge-plugin" } ]
Yes?
For me it no longer doing the "merging", though it does not give any error. Same composer files worked two days back.
Any new changes appeared in recent days on https://github.com/mcaskill/composer-merge-plugin ?
If you've landed here looking for a version of the
wikimedia/composer-merge-plugin
compatible with Composer 2.0, please see https://github.com/wikimedia/composer-merge-plugin/pull/189 and help test!It seems like composer 2.0 is right around the corner. Downloading
https://getcomposer.org/composer.phar
already gives you a 2.0 build.Are there any plans to make this plugin compatible? It currently explicitly requires a v1 composer api to be present.