4

I'm trying to manage a Drupal 8 site entirely with composer. However, I need a -dev version of one module (search_api_solr) with a patch. How do I tell composer to just leave this module on the dev version for the time being and not touch it during update ?

Relevant part of my composer.json looks like this

"require": {
        "composer/installers": "^1.0.21",
        "drupal-composer/drupal-scaffold": "dev-master",
        "drupal/admin_toolbar": "^1.18",
        "drupal/bootstrap": "^3.2",
        "drupal/coffee": "^1.0@beta",
        "drupal/config_tools": "^1.0@alpha",
        "drupal/console": "~1.0",
        "drupal/core": "~8.2",
        "drupal/delete_all": "^1.0@alpha",
        "drupal/devel": "^1.0@RC",
        "drupal/facets": "^1.0@alpha",
        "drupal/imce": "^1.5",
        "drupal/masquerade": "^2.0@beta",
        "drupal/migrate_manifest": "^1.4",
        "drupal/migrate_plus": "^3.0@beta",
        "drupal/migrate_tools": "^3.0@beta",
        "drupal/migrate_upgrade": "^2.0",
        "drupal/pathauto": "^1.0@RC",
        "drupal/search_api": "1.0@beta",
        "drupal/search_api_sorts": "^1.0@alpha",
        "wikimedia/composer-merge-plugin": "~1.3",
        "drupal/search_api_solr": "8.x-1.x-dev"
    },
    "minimum-stability": "dev",
    "prefer-stable": true, 

I've specified the search_api_solr version according to this advice. However, when I run composer update I get:

Your requirements could not be resolved to an installable set of packages. The requested package drupal/search_api_solr 8.x-1.x-dev exists as drupal/search_api_solr[...] but these are rejected by your constraint.

EDIT: Meanwhile I have worked around this by removing the drupal/search_api_solr requirement completely from the composer.json, explicitly listing solarium/solarium instead and installing the patched version of search_api_solr-8.x-1.x-dev manually into the modules/unstable directory. Now composer update works as it shold without overwriting the patch.

3
  • I think the module version should be specified as 1.x-dev, not 8.x-1.x-dev. Are you using the updated composer endpoint for Drupal packages?
    – Kevin
    Commented May 2, 2017 at 15:22
  • Also, you can specify a commit hash to 'lock' a dev version to specific commit instead of rolling dev updates.
    – Kevin
    Commented May 2, 2017 at 15:22
  • As far as patches go you can use composer-patches add on to do that. Check out the Drupal Composer project or Acquia BLT to see how it is done.
    – Kevin
    Commented May 2, 2017 at 15:39

1 Answer 1

2

Firstly, the 8.x- is not part of the composer version; the correct version is 1.x-dev or dev-1.x.

However, composer require drupal/search_api_solr:1.x-dev always updates to the latest revision on the dev branch. If you want to stay on a specific commit and prevent updates entirely, use something like composer require drupal/search_api_solr:1.x-dev#46e16862.

1
  • @christoph.burschka I want to download an installation profile from github, but when I do composer require it gives me error regarding a module that it does not match the constraint. In composer.json of that install profile, the module is in require section like this "drupal/block_access": "dev-8.x-1.x#1cd59ba6856c897afae2551feaa8e6b7f312489c" This is the repo github.com/UH-StudentServices/student_guide
    – Umair
    Commented Aug 1, 2021 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.