Score:1

Add Composer to an existing site

in flag

I built a Drupal 8.9 site with Composer on a DEV server and copied the files (& db) over to the LIVE server.

The LIVE server did not have Composer installed previously so I installed it, locally.

The new website has its composer.json file from when I created the site and added modules.

I tried composer update to verify that composer will work when the time comes.

It fails and I don't know if I need to rip out the website and re-create it again (then copy select files back over).


When I run it I get the following output:

Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.

Problem 1
    
    - Conclusion: don't install drupal/core-recommended 8.9.x-dev (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.8.7 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.8.8 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.8.9 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.8.10 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.8.11 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.8.12 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.0 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.1 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.2 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.3 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.4 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.5 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.6 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.7 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.8 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.9 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.10 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.11 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.12 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.13 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.14 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.15 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.16 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.17 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.18 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.19 (conflict analysis result)
    - Conclusion: don't install drupal/core-recommended 8.9.20 (conflict analysis result)
    - drupal/core-recommended[8.8.0-beta1, ..., 8.9.0-rc1] require composer/installers v1.7.0 -> satisfiable by -> composer/installers[v1.7.0].
    - composer/installers v1.7.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.1.0] but it does not match the constraint.
    - symfony/polyfill-mbstring 1.23.x-dev is an alias of symfony/polyfill-mbstring dev-main and thus requires it to be installed too.
    - easyrdf/easyrdf 0.9.1 requires ext-mbstring * -> satisfiable by symfony/polyfill-mbstring[dev-main, 1.23.x-dev (alias of dev-main)].
    - You can only install one version of a package, so only one of these can be installed: symfony/polyfill-mbstring[dev-main, v1.0.0, ..., v1.23.1].
    - drupal/core-recommended 8.8.x-dev requires easyrdf/easyrdf 0.9.1 -> satisfiable by easyrdf/easyrdf[0.9.1].
    - drupal/core-recommended 8.8.x-dev requires symfony/polyfill-mbstring v1.12.0 -> satisfiable by symfony/polyfill-mbstring[v1.12.0].
    - Root composer.json requires drupal/core-recommended ^8.8 -> satisfiable by drupal/core-recommended[8.8.0-beta1, ..., 8.9.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.ini
    - /etc/php.ini
    - /etc/php.d/20-bz2.ini
    - /etc/php.d/20-calendar.ini
    - /etc/php.d/20-ctype.ini
    - /etc/php.d/20-curl.ini
    - /etc/php.d/20-dom.ini
    - /etc/php.d/20-exif.ini
    - /etc/php.d/20-fileinfo.ini
    - /etc/php.d/20-ftp.ini
    - /etc/php.d/20-gd.ini
    - /etc/php.d/20-gettext.ini
    - /etc/php.d/20-iconv.ini
    - /etc/php.d/20-json.ini
    - /etc/php.d/20-mysqlnd.ini
    - /etc/php.d/20-pdo.ini
    - /etc/php.d/20-phar.ini
    - /etc/php.d/20-simplexml.ini
    - /etc/php.d/20-sockets.ini
    - /etc/php.d/20-sqlite3.ini
    - /etc/php.d/20-tokenizer.ini
    - /etc/php.d/20-xml.ini
    - /etc/php.d/20-xmlwriter.ini
    - /etc/php.d/20-xsl.ini
    - /etc/php.d/30-mcrypt.ini
    - /etc/php.d/30-mysqli.ini
    - /etc/php.d/30-pdo_mysql.ini
    - /etc/php.d/30-pdo_sqlite.ini
    - /etc/php.d/30-wddx.ini
    - /etc/php.d/30-xmlreader.ini
    - /etc/php.d/40-zip.ini 

You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Running php --ini comes up with a matching list


Contents of my composer.json file:

$ clear && cat composer.json
{
  "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"
  }
],
"require": {
  "composer/installers": "^1.2",
  "drupal/block_class": "^1.3",
  "drupal/bootstrap": "^3.23",
  "drupal/captcha": "^1.2",
  "drupal/core-composer-scaffold": "^8.8",
  "drupal/core-project-message": "^8.8",
  "drupal/core-recommended": "^8.8",
  "drupal/mask": "^2.0@alpha",
  "drupal/recaptcha": "^3.0",
  "drupal/webform": "^6.1"
},
"conflict": {
  "drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
  "sort-packages": true
},
"extra": {
  "drupal-scaffold": {
    "locations": {
      "web-root": "web/"
    }
  },
  "installer-paths": {
    "web/core": [
      "type:drupal-core"
    ],
    "web/libraries/{$name}": [
      "type:drupal-library"
    ],
    "web/modules/contrib/{$name}": [
      "type:drupal-module"
    ],
    "web/profiles/contrib/{$name}": [
      "type:drupal-profile"
    ],
    "web/themes/contrib/{$name}": [
      "type:drupal-theme"
    ],
    "drush/Commands/contrib/{$name}": [
      "type:drupal-drush"
    ],
    "web/modules/custom/{$name}": [
      "type:drupal-custom-module"
    ],
    "web/themes/custom/{$name}": [
      "type:drupal-custom-theme"
    ]
  },
  "drupal-core-project-message": {
    "include-keys": [
      "homepage",
      "support"
    ],
    "post-create-project-cmd-message": [
      "<bg=blue;fg=white>                                                         </>",
      "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
      "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
      "<bg=blue;fg=white>                                                         </>",
      "",
      "<bg=yellow;fg=black>Next steps</>:",
      "  * Install the site: https://www.drupal.org/docs/8/install",
      "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
      "  * Get support: https://www.drupal.org/support",
      "  * Get involved with the Drupal community:",
      "      https://www.drupal.org/getting-involved",
      "  * Remove the plugin that prints this message:",
      "      composer remove drupal/core-project-message"
    ]
  }
}
cn flag
From the error it seems you need to install php mbstring
Score:2
de flag

I tried composer update to verify that composer will work when the time comes.

To verify if it will work when the time comes, you would want to run composer install. This will attempt to install the set of dependencies according to what is listed in the composer.lock file. Running composer update attempts to update all your modules to the newest versions. Running this on your production server without having run it locally would result in your production server having a different untested set of module versions than your local system. You would never want to run composer update on a production server, only ever composer install. You can read more about it here (shameless self plug): https://www.morpht.com/blog/drupal-and-composer-part-1-understanding-composer#synchronizing-project-versions

As to your issue with the update, I believe it lies here:

composer/installers v1.7.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.1.0] but it does not match the constraint.

Your composer.json is trying to install composer/installers, which specifies a version beginning with 1.0, but Composer has only found 2.0. I think that this is a Composer version 1 vs. a Composer version 2 issue. If I recall correctly, when you have upgraded Composer to version 2, it cannot find composer/installers version 1.

You can try running composer self-update --1 to downgrade to Composer version 1 (note that you can switch back to v2 with composer self-update --2). If you find that composer update works using Composer version 1, then you'll need to resolve your conflict before upgrading to Composer 2. That's a different topic though.

Hometoy avatar
in flag
On my DEV server I started out with Compose ver.1 and then `self-update` to ver. 2. Unfrotunately still get the errors with both versions. At least with ver. 1 I got a new error about "out of memory" so I increased the memory_allocation and now just keep getting the same errors.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.