On a Drupal 8.5.6 site I am trying via Composer to install the dev version of Coder. I need this version in order to be able to apply patch #40 from issue "Support PHP_CodeSniffer version ^3.2.0" which will allow to bump quizlabs/php_codesniffer's version from v2 to v3.
For info, since Drupal 8.3 Drupal Core's composer.json specifies:
"require-dev": {
...
"drupal/coder": "^8.2.12",
...
"minimum-stability": "dev",
"prefer-stable": true,
...If I run Composer to add drupal/coder:2.x-dev, I got the following:
$ composer require --dev drupal/coder:2.x-dev
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package drupal/coder ^8.2.12 is satisfiable by drupal/coder[8.2.12] but these conflict with your requirements or minimum-stability.
Installation failed, reverting ./composer.json to its original content.And if I edit core/composer.json to have "drupal/coder": "2.x-dev" and then run Composer, I got the following:
$ composer update drupal/coder
Loading composer repositories with package information
Updating dependencies (including require-dev)
[Composer\DependencyResolver\SolverProblemsException]
Problem 1
- The requested package drupal/coder ^8.2 exists as drupal/coder[2.x-dev, dev-2.x] but these are rejected by your constraint.
So, how could we get drupal/coder dev version within a Drupal 8.5.6 installation?
Comments
Comment #2
benoit.borrel commentedComment #3
JvE commentedcomposer show drupal/coder --allis your friend.The version you're looking for is
dev-8.x-2.xComment #4
benoit.borrel commented@JvE, thanks for your advice but it didn't fix the issues and generated similar errors as it is a constraint resolving to the same version.
Since "wikimedia/composer-merge-plugin" is used, the solution I found was to set Composer's conflict resolution engine to the "first version specified wins" conflict resolution strategy using a combination of "replace" and "ignore-duplicates" values.
At the end my project's composer.json was:
Comment #5
benoit.borrel commentedComment #6
benoit.borrel commentedMarked as fixed and linked to Component "Documentation". May be this how to should be added to Coder's documentation.
Comment #7
JvE commentedIf you edit
core/composer.jsonand replace^8.2.12withdev-8.x-2.xthencomposer updateshould work fine.Trying to add drupal/coder:dev-8.x-2.x to the top-level composer.json will fail since that conflicts with the core/composer.json
Glad to see you got it working for you anyway.
Comment #8
benoit.borrel commented@JvE I did also tried to edit
core/composer.jsonand replace^8.2.12withdev-8.x-2.xthencomposer update drupal/coder, but got similar errors as those described in my original post.Anyway even successful that would have been hacky. The solution I found and described in #4 is may be not the best but at least is clean.