Composer error when installing drush in DDEV local dev env.

Created on 13 October 2024, 3 months ago

Problem/Motivation

When following the guide setting up local dev β†’ to review or improve a core patch there is a composer error when we try to install drush and cannot setup a local dev site.

When running

ddev composer require drush/drush

this is the composer error you see:

Problem 1
- Root composer.json requires drupal/core 1.0.0 (exact version match: 1.0.0 or 1.0.0.0), found drupal/core[dev-main] but it does not match the constraint.
Problem 2
- Root composer.json requires drupal/core-project-message 1.0.0 (exact version match: 1.0.0 or 1.0.0.0), found drupal/core-project-message[dev-main] but it does not match the constraint.
Problem 3
- Root composer.json requires drupal/core-vendor-hardening 1.0.0 (exact version match: 1.0.0 or 1.0.0.0), found drupal/core-vendor-hardening[dev-main] but it does not match the constraint.
running

Steps to reproduce

Follow local dev guide for ddev see the "Install the environment with DDEV" section and follow the steps, steps reproduced below

git clone https://git.drupalcode.org/project/drupal.git d11one
cd d11one
ddev config --project-type drupal --docroot .
ddev start
ddev composer install
ddev composer require drush/drush

at the drush install step the installtion fails with error above.

Proposed resolution

No current resolution, but a workaround is also mentioned in the documentation:

1. Edit composer.json and change from "drupal/core": "self.version", to "drupal/core": "dev-main".
2. Same for drupal/core-project-message and drupal/core-vendor-hardening.
3. Remove composer.lock

then run ddev composer install and install drush - it seems to work after this.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

composer

Created by

πŸ‡¬πŸ‡§United Kingdom nidash

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nidash
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    Adding OS and DDEV version in the Issue Summary, since I don't get this error, using Debian 12 and DDEV 1.23.4. So the major difference seems to be OS ...

  • πŸ‡³πŸ‡±Netherlands spokje

    What composer version was used when the error occurred?
    The output of $ composer -v would be most welcome.

  • I can't reproduce this as written. Let's also have a look at the composer.json file because those errors don't make sense.

    I don't see a connection with this issue and πŸ› [PP-1] Performance issues with path alias generated queries on PostgreSQL Postponed except that someone complained about this there so I am removing it, as I suppose whatever this is could happen any time under some circumstances.

  • I forgot to remove the link.

  • πŸ‡¬πŸ‡§United Kingdom nidash
  • I updated the summary to include that this issue follows from the discussion thread on that documentation page, which would have been good to know up front. We really need to see the composer.json file now.

  • πŸ‡¬πŸ‡§United Kingdom nidash
  • Just checking: is that the one that does, or does not work?

  • πŸ‡¬πŸ‡§United Kingdom nidash

    Thats the one that does not work.

  • That's the default composer.json in the repo.

    Following https://www.drupal.org/community/contributor-guide/reference-information... β†’ on a Mac I still cannot reproduce this. Every step runs perfectly and step 9, the workaround, is unnecessary. .ddev/config.yaml is as follows:

    name: drupal-test
    type: drupal
    docroot: .
    php_version: "8.3"
    webserver_type: nginx-fpm
    xdebug_enabled: false
    additional_hostnames: []
    additional_fqdns: []
    database:
        type: mariadb
        version: "10.11"
    use_dns_when_possible: true
    composer_version: "2"
    web_environment: []
    corepack_enable: true
    
    # Key features of DDEV's config.yaml:
    
    # name: <projectname> # Name of the project, automatically provides
    #   http://projectname.ddev.site and https://projectname.ddev.site
    
    # type: <projecttype>  # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress
    # See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more
    

    I tested on an M1 architecture Mac. docker image ls shows v1.23.4 for the DDEV image versions.

  • πŸ‡¬πŸ‡§United Kingdom nidash

    I use a MacBook Air 2020 M1 Sonoma 14.6.1, I saw someone report this on slack on the #contrib channel and i was able to replicate it, the workaround was recommended by him too.

    ITEM VALUE
    DDEV version v1.23.4
    architecture arm64
    cgo_enabled 0
    db ddev/ddev-dbserver-mariadb-10.11:v1.23.4
    ddev-ssh-agent ddev/ddev-ssh-agent:v1.23.4
    docker 27.2.0
    docker-api 1.47
    docker-compose v2.29.1
    docker-platform docker-desktop
    global-ddev-dir /Users/nidash/.ddev
    mutagen 0.17.2
    os darwin
    router ddev/ddev-traefik-router:v1.23.4
    web ddev/ddev-webserver:v1.23.4

  • I believe this is happening on your end and is happening to some others. What we need is to understand why.

    ddev version
     ITEM             VALUE
     DDEV version     v1.23.4
     architecture     arm64
     cgo_enabled      0
     db               ddev/ddev-dbserver-mariadb-10.11:v1.23.4
     ddev-ssh-agent   ddev/ddev-ssh-agent:v1.23.4
     docker           27.1.2
     docker-api       1.46
     docker-compose   v2.29.1
     docker-platform  lima
     global-ddev-dir  /Users/cjm/.ddev
     mutagen          0.17.2
     os               darwin
     router           ddev/ddev-traefik-router:v1.23.4
     web              ddev/ddev-webserver:v1.23.4
    

    I doubt platform issues are very much involved here because this is something to do with Composer.

  • Run Composer in its most verbose mode when trying to install Drush. Post the output here.

    For all I know this could be a regional, CDN issue.

  • Also let’s see composer show -a drupal/core. Add -vvv if it allows that.

  • πŸ‡¬πŸ‡§United Kingdom nidash

    here is the output

    Running 2.8.1 (2024-10-04 11:31:01) with PHP 8.3.10 on Linux / 6.10.4-linuxkit
    Reading ./composer.json (/var/www/html/composer.json)
    Loading config file ./composer.json (/var/www/html/composer.json)
    Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
    Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
    Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
    Executing command (/var/www/html): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
    Executing command (/var/www/html): git describe --exact-match --tags
    Executing command (CWD): git --version
    Executing command (/var/www/html): git log --pretty="%H" -n1 HEAD --no-show-signature
    Executing command (/var/www/html): hg branch
    Executing command (/var/www/html): fossil branch list
    Executing command (/var/www/html): fossil tag list
    Executing command (/var/www/html): svn info --xml
    Failed to initialize global composer: Composer could not find the config file: /home/nidash/.composer/composer.json

    Reading /var/www/html/vendor/composer/installed.json
    Loading plugin Composer\Installers\Plugin (from composer/installers)
    Loading plugin PHPCSStandards\Composer\Plugin\Installers\PHPCodeSniffer\Plugin (from dealerdirect/phpcodesniffer-composer-installer)
    Loading plugin Http\Discovery\Composer\Plugin (from php-http/discovery)
    Loading plugin Drupal\Composer\Plugin\ProjectMessage\MessagePlugin (from drupal/core-project-message)
    Loading plugin Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin (from drupal/core-vendor-hardening)
    Loading plugin PHPStan\ExtensionInstaller\Plugin (from phpstan/extension-installer)
    Executing command (/var/www/html/core/): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
    Executing command (/var/www/html/core/): git describe --exact-match --tags
    Executing command (/var/www/html/core/): git log --pretty="%H" -n1 HEAD --no-show-signature
    Executing command (/var/www/html/core/): hg branch
    Executing command (/var/www/html/core/): fossil branch list
    Executing command (/var/www/html/core/): fossil tag list
    Executing command (/var/www/html/core/): svn info --xml
    name : drupal/core
    descrip. : Drupal is an open source content management platform powering millions of websites and applications.
    keywords :
    versions : dev-main
    type : drupal-core
    license : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved) https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText
    homepage :
    source : []
    dist : [path] core 946773df28ad729a17c4002a6b5740a746b6deb5
    names : drupal/core, drupal/core-annotation, drupal/core-assertion, drupal/core-class-finder, drupal/core-datetime, drupal/core-dependency-injection, drupal/core-diff, drupal/core-discovery, drupal/core-event-dispatcher, drupal/core-file-cache, drupal/core-file-security, drupal/core-filesystem, drupal/core-front-matter, drupal/core-gettext, drupal/core-graph, drupal/core-http-foundation, drupal/core-php-storage, drupal/core-plugin, drupal/core-proxy-builder, drupal/core-render, drupal/core-serialization, drupal/core-transliteration, drupal/core-utility, drupal/core-uuid, drupal/core-version

    autoload
    psr-4
    Drupal\Core\ => lib/Drupal/Core
    Drupal\Component\ => lib/Drupal/Component
    classmap
    lib/Drupal.php, lib/Drupal/Component/DependencyInjection/Container.php, lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php, lib/Drupal/Component/FileCache/FileCacheFactory.php, lib/Drupal/Component/Utility/Timer.php, lib/Drupal/Component/Utility/Unicode.php, lib/Drupal/Core/Cache/Cache.php, lib/Drupal/Core/Cache/CacheBackendInterface.php, lib/Drupal/Core/Cache/CacheTagsChecksumInterface.php, lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php, lib/Drupal/Core/Cache/CacheTagsInvalidatorInterface.php, lib/Drupal/Core/Cache/DatabaseBackend.php, lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php, lib/Drupal/Core/Database/Connection.php, lib/Drupal/Core/Database/Database.php, lib/Drupal/Core/Database/StatementInterface.php, lib/Drupal/Core/DependencyInjection/Container.php, lib/Drupal/Core/DrupalKernel.php, lib/Drupal/Core/DrupalKernelInterface.php, lib/Drupal/Core/Installer/InstallerRedirectTrait.php, lib/Drupal/Core/Site/Settings.php, lib/Drupal/Component/Datetime/Time.php
    files

    requires
    ext-date *
    ext-dom *
    ext-filter *
    ext-gd *
    ext-hash *
    ext-json *
    ext-pcre *
    ext-pdo *
    ext-session *
    ext-simplexml *
    ext-spl *
    ext-tokenizer *
    ext-xml *
    ext-zlib *
    php >=8.3.0
    symfony/console ^7.1
    symfony/dependency-injection ^7.1
    symfony/event-dispatcher ^7.1
    symfony/filesystem ^7.1
    symfony/finder ^7.1
    symfony/http-foundation ^7.1
    symfony/http-kernel ^7.1
    symfony/mailer ^7.1
    symfony/mime ^7.1
    symfony/routing ^7.1
    symfony/serializer ^7.1
    symfony/validator ^7.1
    symfony/process ^7.1
    symfony/polyfill-iconv ^1.26
    symfony/yaml ^7.1
    twig/twig ^3.14.0
    doctrine/annotations ^2.0
    doctrine/lexer ^2.0
    guzzlehttp/guzzle ^7.5
    guzzlehttp/psr7 ^2.4.5
    egulias/email-validator ^3.2.1|^4.0
    masterminds/html5 ^2.7
    symfony/psr-http-message-bridge ^7.1
    composer-runtime-api ^2.1
    composer/semver ^3.3
    asm89/stack-cors ^2.1
    pear/archive_tar ^1.4.14
    psr/log ^3.0
    mck89/peast ^1.14
    sebastian/diff ^4|^5

    suggests
    ext-zip Needed to extend the plugin.manager.archiver service capability with the handling of files in the ZIP format.

    conflicts
    drush/drush <12.4.3

    replaces
    drupal/core-annotation self.version
    drupal/core-assertion self.version
    drupal/core-class-finder self.version
    drupal/core-datetime self.version
    drupal/core-dependency-injection self.version
    drupal/core-diff self.version
    drupal/core-discovery self.version
    drupal/core-event-dispatcher self.version
    drupal/core-file-cache self.version
    drupal/core-file-security self.version
    drupal/core-filesystem self.version
    drupal/core-front-matter self.version
    drupal/core-gettext self.version
    drupal/core-graph self.version
    drupal/core-http-foundation self.version
    drupal/core-php-storage self.version
    drupal/core-plugin self.version
    drupal/core-proxy-builder self.version
    drupal/core-render self.version
    drupal/core-serialization self.version
    drupal/core-transliteration self.version
    drupal/core-utility self.version
    drupal/core-uuid self.version
    drupal/core-version self.version

  • That is the output of which command? I asked for two. Please include the command with its output and surround them in <code> tags for readability here.

  • πŸ‡¬πŸ‡§United Kingdom nidash

    edited my comment above for readability hope that helps.

  • Here is the diff between my output (at left) and yours (at right) just after step 7 in the doc β†’ .

    1c1
    < Running 2.8.1 (2024-10-04 11:31:01) with PHP 8.3.10 on Linux / 6.8.0-45-generic
    ---
    > Running 2.8.1 (2024-10-04 11:31:01) with PHP 8.3.10 on Linux / 6.10.4-linuxkit
    8c8,15
    < Failed to initialize global composer: Composer could not find the config file: /home/cjm/.composer/composer.json
    ---
    > Executing command (/var/www/html): git describe --exact-match --tags
    > Executing command (CWD): git --version
    > Executing command (/var/www/html): git log --pretty="%H" -n1 HEAD --no-show-signature
    > Executing command (/var/www/html): hg branch
    > Executing command (/var/www/html): fossil branch list
    > Executing command (/var/www/html): fossil tag list
    > Executing command (/var/www/html): svn info --xml
    > Failed to initialize global composer: Composer could not find the config file: /home/nidash/.composer/composer.json
    17a25,30
    > Executing command (/var/www/html/core/): git describe --exact-match --tags
    > Executing command (/var/www/html/core/): git log --pretty="%H" -n1 HEAD --no-show-signature
    > Executing command (/var/www/html/core/): hg branch
    > Executing command (/var/www/html/core/): fossil branch list
    > Executing command (/var/www/html/core/): fossil tag list
    > Executing command (/var/www/html/core/): svn info --xml
    20,21c33,34
    < keywords :
    < versions : * 11.x-dev
    ---
    > keywords : 
    > versions : dev-main
    24,25c37,38
    < homepage :
    < source   : []
    ---
    > homepage : 
    > source   : []  
    27d39
    < path     : /var/www/html/core
    
  • πŸ‡¬πŸ‡§United Kingdom nidash

    The diff made me wonder if this was something to do with docker installation, then i looked into this in more detail - I was playing with rancher and docker desktop, i noticed the context for kubernetes in docker desktop was set as rancher, but rancher i had uninstall. This prompted me to uninstall docker desktop and install docker and colima. after trying this I was able to do the ddev composer require drush/drush.

    I will reachout to the other user who faced this issue and check with him - but thanks for your help @cilefen. I will leave the issue open till then, but aim to close soon.

  • πŸ‡¬πŸ‡§United Kingdom nidash

    It seems the problem is related to incorrect docker installation.

  • πŸ‡¬πŸ‡§United Kingdom nidash
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    Great that this got cleared up, thanks for helping out @cilefen, and thanks for updating the documentation @nidash.

Production build 0.71.5 2024