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

benoit.borrel created an issue. See original summary.

benoit.borrel’s picture

Issue summary: View changes
JvE’s picture

composer show drupal/coder --all is your friend.
The version you're looking for is dev-8.x-2.x

benoit.borrel’s picture

@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:

  "require-dev": {
    ...
    "drupal/coder": "dev-8.x-2.x",
    ...
  },
  ...
  "extra": {
    ...
    "merge-plugin": {
      "include": [
        "core/composer.json"
      ],
      ...
      "replace": false,
      "ignore-duplicates": true,
      ...
    },
  }
benoit.borrel’s picture

Status: Active » Fixed
benoit.borrel’s picture

Component: Miscellaneous » Documentation

Marked as fixed and linked to Component "Documentation". May be this how to should be added to Coder's documentation.

JvE’s picture

If you edit core/composer.json and replace ^8.2.12 with dev-8.x-2.x then composer update should 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.

benoit.borrel’s picture

@JvE I did also tried to edit core/composer.json and replace ^8.2.12 with dev-8.x-2.x then composer 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.