wikimedia / composer-merge-plugin

Merge one or more additional composer.json files at Composer runtime
MIT License
933 stars 161 forks source link

Compatibilty with Composer 2.0 #184

Closed tobias-kuendig closed 3 years ago

tobias-kuendig commented 4 years ago

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.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires wikimedia/composer-merge-plugin 1.4.1 -> satisfiable by wikimedia/composer-merge-plugin[v1.4.1].
    - wikimedia/composer-merge-plugin v1.4.1 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match your constraint.
mcaskill commented 3 years ago

@junaidpv Any future replies concerning issues with this fork should take place in #189.

To answer your question: yes, there have been some changes to the PR in the last three days.

If you were already using the fork prior to Sunday (2021-01-31) then merged dependencies shouldn't have been affected.

If you are mixing Merge Plugin v1.4 and this v1.5 fork, then it's very likely that your merged dependencies will be removed if updating the plugin using only Composer 2.

enjibby commented 3 years ago

I have arrived at this issue from the Pin at the top of the issue list. Is there a chance you could replace that pin with a reference to #189 ?

AntoninSlejska commented 3 years ago

@mcaskill We are using:

"require": {
    "wikimedia/composer-merge-plugin": "dev-feature/composer-v2"
},
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/mcaskill/composer-merge-plugin",
        "no-api": true
    }
]

Four days ago was everything okay. Now I get the following error message:

Fatal error: Uncaught Error: Call to undefined method Wikimedia\Composer\Merge\ExtraPackage::getMergedRequirements() in phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(220) : eval()'d code:287
Stack trace:
#0 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(220) : eval()'d code(254): Wikimedia\Composer\MergePlugin_composer_tmp0->mergeFile(Object(Composer\Package\RootPackage), 'composer.local....')
#1 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(220) : eval()'d code(215): Wikimedia\Composer\MergePlugin_composer_tmp0->mergeFiles(Array, false)
#2 [internal function]: Wikimedia\Composer\MergePlugin_composer_tmp0->onInstallUpdateOrDump(Object(Composer\Script\Event))
#3 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(172): call_user_func(Array, Object(Composer\Script\Event))
#4 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(101): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Sc in phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(220) : eval()'d code on line 287
mcaskill commented 3 years ago

@AntoninSlejska This issue should take place in #189.

Not sure what is going on for ExtraPackage::getMergedRequirements() to be undefined. It appears MergePlugin and ExtraPackage are some how out of sync which would be impossible since these changes occurred in the same commit. I am not familiar with no-api, not sure what it does and if it might affect things. I'd suggest deleting the package from your vendor directory and reinstalling.

neclimdul commented 3 years ago

If it happened in the same commit, is it possible that composer was updating merge plugin when this happened? Plugins can interact weird with class autoloading when composer is updating them.

reedy commented 3 years ago

I have arrived at this issue from the Pin at the top of the issue list. Is there a chance you could replace that pin with a reference to #189 ?

I don't think you can pin PRs, unfortunately

Which is why I changed the first part of the original issue description to point to 189 instead

chrissnyder2337 commented 3 years ago

@AntoninSlejska I am experiencing the same thing too. it worked last week but got the same error as you today.

reedy commented 3 years ago

See https://github.com/wikimedia/composer-merge-plugin/pull/189#issuecomment-775315971 / https://github.com/wikimedia/composer-merge-plugin/pull/189/commits/b8b8cb4db48720687997fb106ea2953374718450

VolCh commented 3 years ago

189 has been merged. Can this issue be closed and version 1.5.0 released now?

smustgrave commented 3 years ago

Had to use "wikimedia/composer-merge-plugin": "dev-feature/composer-v2 as 1.5.0" to get mine to work. dev-master wasn't working for me.

mcaskill commented 3 years ago

Support for Composer v2 has been finally resolved with the release of Merge Plugin v2.0.0. See #206 for details.

Thanks @tstarling

smustgrave commented 3 years ago

Do you know when a release will happen?

mlocati commented 3 years ago

Do you know when a release will happen?

@smustgrave We already have version 2.0.0 and 2.0.1 published - see https://packagist.org/packages/wikimedia/composer-merge-plugin

mcaskill commented 3 years ago

Do you know when a release will happen?

@smustgrave I don't know when there will be GitHub Release description (/cc @tstarling) but the package is tagged as @mlocati and I pointed out.

sjerdo commented 3 years ago

Thanks for the update for Composer 2 support!

README.md still contains references to 1.5.x or 1.5. These should be changed to 2.x and 2.0.0

Composer Merge Plugin 1.4.x (and older) requires Composer 1.x. Composer Merge Plugin 1.5.x (and newer) is compatible with both Composer 2.x and 1.x.

If you are already using Composer Merge Plugin 1.4 (or older) and you are updating the plugin to 1.5 (or newer), it is recommended that you update the plugin first using Composer 1.

reedy commented 3 years ago

Both 1.5 references fixed.

https://github.com/wikimedia/composer-merge-plugin/releases/tag/v2.0.1 Github "release" created; though I'm not sure how many people actually use that for PHP libraries :)

I'll wait a little bit, but we can tag a 2.0.2 when there's been a bit more testing to bring in the minor README tweaks.

carloscarucce commented 3 years ago

Still not fully compatible with composer 2?

XedinUnknown commented 3 years ago

@carloscarucce, why, what symptoms are you experiencing?

carloscarucce commented 3 years ago

@XedinUnknown by the time it hasn't loaded any of my subfolders composer.jsons. I downgraded my composer to v1 then it worked.

schmunk42 commented 3 years ago

@XedinUnknown by the time it hasn't loaded any of my subfolders composer.jsons. I downgraded my composer to v1 then it worked.

I remember I had to run composer update 3 times when upgrading a project to composer 2 with this plugin.

smustgrave commented 3 years ago

I'm still getting errors using 2.0.1

from package repo (defining 1 package) has higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable.

Seems whatever is in my merge-plugin include tops my main composer file.

schmunk42 commented 3 years ago

@smustgrave Did you try setting https://github.com/wikimedia/composer-merge-plugin#ignore-duplicates ?

smustgrave commented 3 years ago

I did. Tried all the settings. Can't resolve the conflict

schmunk42 commented 3 years ago

Do you run a full update or just one package?

smustgrave commented 3 years ago

Full update. Just composer update

smustgrave commented 3 years ago

Here's my composer file if that helps. The conflict is coming from ckeditor/link. The file I'm including in the merge-plugin for webform also loads ckeditor/link but an older version. I would expect that my composer file would beat anything being merged or is that wrong?

{ "name": "drupal/recommended-project", "description": "Project template for Drupal 8 projects with a relocated document root", "type": "project", "license": "GPL-2.0-or-later", "homepage": "https://www.drupal.org/project/drupal", "support": { "docs": "https://www.drupal.org/docs/user_guide/en/index.html", "chat": "https://www.drupal.org/node/314178" }, "repositories": [ { "type": "composer", "url": "https://packages.drupal.org/8" }, { "type": "package", "package": { "name": "jquery/jquery-ui-touch-punch", "version": "0.2.3", "dist": { "url": "https://github.com/furf/jquery-ui-touch-punch/archive/master.zip", "type": "zip" }, "type": "drupal-library" } }, { "type": "package", "package": { "name": "ckeditor/fakeobjects", "version": "4.14.1", "dist": { "url": "https://download.ckeditor.com/fakeobjects/releases/fakeobjects_4.14.1.zip", "type": "zip" }, "type": "drupal-library" } }, { "type": "package", "package": { "name": "ckeditor/iframe", "version": "4.14.1", "dist": { "url": "https://download.ckeditor.com/iframe/releases/iframe_4.14.1.zip", "type": "zip" }, "type": "drupal-library" } }, { "type": "package", "package": { "name": "ckeditor/link", "version": "4.15.0", "dist": { "url": "https://download.ckeditor.com/link/releases/link_4.15.0.zip", "type": "zip" }, "type": "drupal-library" }, "canonical": false }, { "type": "package", "package": { "name": "jackmoore/colorbox", "version": "dev-master", "dist": { "url": "https://github.com/jackmoore/colorbox/archive/master.zip", "type": "zip" }, "type": "drupal-library" } } ], "require": { "ext-json": "", "ckeditor/fakeobjects": "4.14.1", "ckeditor/iframe": "4.14.1", "ckeditor/link": "4.15.0", "composer/installers": "^1.9", "consolidation/robo": "^2.1", "cweagans/composer-patches": "^1.6", "drupal/address": "~1.0", "drupal/admin_toolbar": "^3.0", "drupal/anchor_link": "^2.4", "drupal/autologout": "^1.3", "drupal/better_exposed_filters": "^5.0@beta", "drupal/block_class": "^1.2", "drupal/block_content_revision_ui": "^2.127", "drupal/block_content_template": "^1.4", "drupal/block_title_link": "^1.1", "drupal/block_visibility_groups": "1.x-dev", "drupal/ckeditor_accordion": "^1.3", "drupal/ckeditor_iframe": "^2.1", "drupal/collapsiblock": "^3.0", "drupal/colorbox": "^1.7", "drupal/components": "^2.0@beta", "drupal/config_ignore": "3.x-dev", "drupal/config_split": "^2.0@beta", "drupal/content_moderation_notifications": "^3.3", "drupal/core-composer-scaffold": "^9.0.0", "drupal/core-project-message": "^9", "drupal/core-recommended": "^9.0.0@stable", "drupal/devel_entity_updates": "^3.0", "drupal/diff": "^1.0", "drupal/easy_breadcrumb": "^1.13", "drupal/entity_browser": "^2.5", "drupal/entity_clone": "^1.0@beta", "drupal/entity_embed": "^1.1", "drupal/entity_reference_revisions": "^1.8", "drupal/extlink": "^1.3", "drupal/facets": "^1.6", "drupal/feeds": "^3.0@alpha", "drupal/feeds_ex": "^1.0@alpha", "drupal/feeds_tamper": "^2.0@beta", "drupal/field_group": "^3.1", "drupal/formdazzle": "^2.1", "drupal/google_analytics": "^3.1", "drupal/google_tag": "^1.4", "drupal/health_check": "^1.2", "drupal/honeypot": "^2.0", "drupal/inline_entity_form": "^1.0@rc", "drupal/jquery_ui_accordion": "^1.1", "drupal/jsonapi_resources": "1.x-dev", "drupal/jsonapi_search_api": "^1.0@beta", "drupal/lark": "^1.0@beta", "drupal/layout_builder_modal": "^1.1", "drupal/layout_builder_restrictions": "^2.7", "drupal/layout_builder_styles": "^1.0@beta", "drupal/link_field_autocomplete_filter": "^1.14", "drupal/linkit": "^6.0@beta", "drupal/mailsystem": "^4.3", "drupal/media_entity_browser": "^2.0@alpha", "drupal/menu_block": "^1.6", "drupal/menu_item_extras": "^2.11", "drupal/menu_link_attributes": "^1.2", "drupal/modal_page": "^4.0", "drupal/paragraphs": "^1.12", "drupal/pathauto": "^1.8", "drupal/phpmailer_smtp": "^2.0", "drupal/publication_date": "2.x-dev@dev", "drupal/purge": "^3.0", "drupal/purge_queuer_url": "^1.0", "drupal/rabbit_hole": "^1.0@beta", "drupal/redirect": "^1.6", "drupal/redirect_after_login": "^2.6", "drupal/redis": "^1.4", "drupal/samlauth": "3.0-alpha2", "drupal/search_api": "^1.17", "drupal/search_api_attachments": "^1.0@beta", "drupal/search_api_exclude_entity": "^1.3", "drupal/search_api_solr": "^4.1", "drupal/simple_sitemap": "^3.7", "drupal/slack": "^1.3", "drupal/smart_trim": "^1.3", "drupal/stage_file_proxy": "1.x-dev", "drupal/svg_image": "^1.14", "drupal/tamper": "^1.0@alpha", "drupal/tooltip_taxonomy": "^1.5", "drupal/twig_field_value": "^2.0", "drupal/twig_tweak": "^3.0", "drupal/uswds_base": "^2.10@alpha", "drupal/views_conditional": "^1.2", "drupal/views_field_view": "^1.0@beta", "drupal/warmer": "^2.0", "drupal/webform": "^6.0", "drupal/webform_views": "^5.0@alpha", "drush/drush": "^10.2", "jackmoore/colorbox": "dev-master", "jquery/jquery-ui-touch-punch": "0.2.3", "predis/predis": "^1.1", "wikimedia/composer-merge-plugin": "^2.0.0" }, "require-dev": { "drupal/core-dev": "^9.0.0", "drupal/devel": "^3.0@dev", "kint-php/kint": "^3.3", "mglaman/drupal-check": "^1.1", "php-parallel-lint/php-console-color": "^0.3.0", "php-parallel-lint/php-console-highlighter": "^0.4.0", "php-parallel-lint/php-parallel-lint": "^1.2" }, "conflict": { "drupal/drupal": "" }, "minimum-stability": "beta", "prefer-stable": true, "extra": { "drupal-scaffold": { "locations": { "web-root": "wwwroot" }, "file-mapping": { "[web-root]/sites/development.services.yml": false } }, "installer-paths": { "wwwroot/core": ["type:drupal-core"], "wwwroot/libraries/{$name}": ["type:drupal-library"], "wwwroot/modules/contrib/{$name}": ["type:drupal-module"], "wwwroot/profiles/contrib/{$name}": ["type:drupal-profile"], "wwwroot/themes/contrib/{$name}": ["type:drupal-theme"], "drush/Commands/contrib/{$name}": ["type:drupal-drush"], "wwwroot/modules/custom/{$name}": ["type:drupal-custom-module"], "wwwroot/themes/custom/{$name}": ["type:drupal-custom-theme"] }, "patches": { "drupal/config_ignore": { "3117694 - Config in active storage not ignored": "https://www.drupal.org/files/issues/2020-05-28/3117694-active-config-25.patch" }, "drupal/search_api": { "Better logging for Search API": "https://www.drupal.org/files/issues/2018-07-30/search-api-catch-exception-2686159-13.patch" }, "drupal/feeds": { "Check for null feeds before processing": "https://www.drupal.org/files/issues/2020-08-30/feeds-deleted-feed-type-3104727-7.patch" }, "drupal/collapsiblock": { "508 fix for jumping collapse links": "https://git.drupalcode.org/project/collapsiblock/-/merge_requests/2/diffs.diff" }, "drupal/tooltip_taxonomy": { "Load library on views": "patches/tooltip_taxonomy/tooltip_taxonomy-load-library-views.patch", "508 fix for tooltip taxonomy": "patches/tooltip_taxonomy/tooltip_taxonomy-508-fixes.patch", "Remove duplicate tooltips": "patches/tooltip_taxonomy/tooltip_taxonomy-remove-duplicate-tooltips.patch" }, "drupal/uswds_base": { "Changing li to span for 508 purposes": "https://git.drupalcode.org/project/uswds_base/-/merge_requests/1.diff" }, "drupal/smart_trim": { "Javascript appearing when HTML is being stripped": "https://git.drupalcode.org/project/smart_trim/-/merge_requests/7.diff" }, "drupal/better_exposed_filters": { "Add fieldset awareness to DateRange Picker": "patches/better_exposed_filters/bef-datepicker-beta1.patch" }, "drupal/modal_page": { "508 Issues: Lost focus and missing ARIA": "patches/modal_pages/modal_page-508-fixes.patch", "Fix issues with modal not showing on multiple pages": "patches/modal_pages/modal_page-show-on-multiple-pages-fix.patch" }, "drupal/paragraphs": { "Integrity constraint violation: 1048 Column 'langcode' cannot be null": "https://www.drupal.org/files/issues/2021-03-01/2901390-76-integrity-constraint-violation-paragraph.patch" }, "drupal/core": { "Off-canvas style resets are overriding styles (especially SVGs) resulting in display issues": "https://www.drupal.org/files/issues/2021-01-06/off-canvas-style-resets-2958588-13.patch", "[PP-1] Implement a generic revision UI": "https://www.drupal.org/files/issues/2021-03-24/2350939-164.patch", "[PP-1] Use generic access API for node and media revision UI": "https://www.drupal.org/files/issues/2021-03-18/3043321-70.patch" } }, "merge-plugin": { "include": [ "wwwroot/modules/contrib/webform/composer.libraries.json" ], "recurse": false, "replace": false, "ignore-duplicates": true, "merge-dev": true, "merge-extra": false, "merge-extra-deep": false, "merge-scripts": false } }, "config": { "platform": { "php": "7.3", "ext-gd": "1" }, "sort-packages": true, "vendor-dir": "vendor" } }

reedy commented 3 years ago

See https://github.com/wikimedia/composer-merge-plugin#replace, you have replace: false

smustgrave commented 3 years ago

Even setting replace: true didn't work. Still get the error.

smustgrave commented 3 years ago

And with both set I get this now [merge-plugin] Both replace and ignore-duplicates are true. These are mutually exclusive. [merge-plugin] Duplicate packages will be ignored.

Now if I add "canonical": false to the repo within the webform composer.libraries.json file it seems to work. But if that desirable? That all modules and libraries have to add this line now?

LukeTowers commented 3 years ago

@smustgrave if you have two different versions of the same package attempting to be loaded then yes, you will have composer complaining about it since the wrong version being loaded for one of those packages could cause the package to break. You should examine both requirements and if there really isn't a reason why they couldn't both use the same version of the dependency; then see if you can make the requirements looser on one composer.json or the other so you can make them use the same version of the dependency.

smustgrave commented 3 years ago

So with these Drupal sites we don't have a lot of control over other modules composer files. Ideally the main composer file should beat out the merged stuff. And the settings don't really seem to have any affect on it. Most likely going to have and downgrade composer or remove the merge-plugin. Until merge-plugin fully works with composer 2.

LukeTowers commented 3 years ago

@smustgrave what is the other module's composer file?

reedy commented 3 years ago

Can we move this to a new/seperate issue please?