2

If I check for outdated artifacts using:

composer outdated "drupal/*"

I can see Core needs updating:

drupal/core                       9.2.3             9.2.4
drupal/core-composer-scaffold     9.2.3             9.2.4
drupal/core-dev                   9.1.5             9.2.4
drupal/core-recommended           9.2.3             9.2.4

...

However, when I try to update:

composer update drupal/core-recommended --with-dependencies

I get the following messages:

Dependency "drupal/core" is also a root requirement, but is not explicitly allowed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Package rector/rector-prefixed is abandoned, you should avoid using it. Use rector/rector instead.
Writing lock file
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class

This site was original built in Drupal 8, but has been upgraded to Drupal 9.

Any suggestions on how I might fix this issue?

My composer.json file is as follows:

{
    "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/address": "^1.9",
        "drupal/advagg": "4.x-dev@dev",
        "drupal/asset_injector": "2.x-dev",
        "drupal/charts": "^5.0@alpha",
        "drupal/coffee": "1.x-dev",
        "drupal/composer_deploy": "^1.6",
        "drupal/config_views": "^2.0",
        "drupal/core": "9.2.3 as 8.9.0",
        "drupal/core-composer-scaffold": "^9.1.5",
        "drupal/core-project-message": "^9.1.5",
        "drupal/core-recommended": "^9.1.5",
        "drupal/devel_entity_updates": "^3.0",
        "drupal/domain": "1.x-dev",
        "drupal/domain_site_settings": "1.x-dev",
        "drupal/dropzonejs": "^2.5",
        "drupal/drupalmoduleupgrader": "^1.7",
        "drupal/dynamic_asset": "1.x-dev",
        "drupal/email_registration": "^1.1",
        "drupal/exclude_node_title": "1.x-dev@dev",
        "drupal/feeds": "3.x-dev",
        "drupal/feeds_tamper": "^2.0",
        "drupal/field_css": "^2.0@RC",
        "drupal/field_formatter_class": "^1.5",
        "drupal/filefield_paths": "1.x-dev",
        "drupal/formblock": "^2.0@beta",
        "drupal/geocoder": "^3.17",
        "drupal/geophp": "^1.0",
        "drupal/group": "1.x-dev@dev",
        "drupal/gtranslate": "^1.13",
        "drupal/image_effects": "^3.1",
        "drupal/jquery_ui": "1.x-dev",
        "drupal/jquery_ui_sortable": "1.x-dev",
        "drupal/leaflet": "^2.1",
        "drupal/libraries": "^3.0@beta",
        "drupal/masquerade": "2.x-dev@dev",
        "drupal/media_directories": "^2.0",
        "drupal/media_library_form_element": "1.x-dev",
        "drupal/media_migration": "1.x-dev@dev",
        "drupal/menu_twig": "^1.4",
        "drupal/migrate_plus": "^5.1",
        "drupal/migrate_process_inline_images": "^1.0",
        "drupal/migrate_source_csv": "3.x-dev@dev",
        "drupal/migrate_tools": "5.x-dev@dev",
        "drupal/ng_lightbox": "^1.0@beta",
        "drupal/office_hours": "^1.3",
        "drupal/optimizedb": "1.x-dev@dev",
        "drupal/paragraphs": "^1.12",
        "drupal/pathauto": "^1.8",
        "drupal/php": "^1.1",
        "drupal/prepopulate": "^2.3",
        "drupal/quiz": "6.x-dev@dev",
        "drupal/recaptcha": "^3.0",
        "drupal/redirect": "^1.6",
        "drupal/search404": "^2.0",
        "drupal/shortcode": "2.0.x-dev@dev",
        "drupal/sitemap": "^2.0@beta",
        "drupal/theme_switcher": "^1.1",
        "drupal/ultimate_cron": "^2.0@alpha",
        "drupal/upgrade_rector": "1.x-dev@dev",
        "drupal/video": "^1.5@alpha",
        "drupal/video_embed_field": "2.x-dev@dev",
        "drupal/views_data_export": "1.x-dev@dev",
        "drupal/views_slideshow": "^4.8",
        "drupal/webform": "^6.0@alpha",
        "drupal/webform_migrate": "1.x-dev@dev",
        "drupal/weight": "^3.2",
        "drupal/xhprof": "^1.0@beta",
        "drush/drush": "^10.4",
        "geocoder-php/google-maps-provider": "^4.6",
        "google/apiclient": "^2.0",
        "phpstan/phpstan": "^0.12.81",
        "webmozart/assert": "^1.10"
    },
    "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"
            ]
        }
    },
    "require-dev": {
        "drupal/core-dev": "^9.1.5",
        "kint-php/kint": "^3.3",
        "mglaman/drupal-check": "^1.1",
        "phpunit/phpunit": "^8.4.1"
    }
}
4
  • Firstly, try composer remove --dev drupal/core-dev. And composer update drupal/core-recommended:^9.2. maybe conflict by core-dev.
    – MrD
    Aug 16, 2021 at 4:45
  • I have just tried composer remove --dev drupal/core-dev. And composer update drupal/core-recommended:^9.2. Still getting "Nothing to install or update". Anyway, thanks for the suggestion Mr D.
    – BrettSh
    Aug 16, 2021 at 5:13
  • 2
    The drupal.org documentation - drupal.org/docs/updating-drupal/… - says to use composer update drupal/core "drupal/core-*" --with-all-dependencies. Does it help?
    – hansfn
    Aug 16, 2021 at 6:27
  • Yeah, I think that's what needs to be done.
    – Jaypan
    Aug 16, 2021 at 6:51

2 Answers 2

8

You have some really dirty hacks in your composer.json. A line like "drupal/core": "9.2.3 as 8.9.0" is a very bad idea and is always going to explode sooner or later. The intention usually is to upgrade Drupal core v9 while keeping v8-only/v9-incompatible modules, but trying to do something like this is just plain wrong.

  1. Remove all lines drupal/core*** except drupal/core-recommended and drupal/core-composer-scaffold. Those two will require all other stuff, the superfluent drupal/core*** just make future upgrading harder.
  2. In your other post there is the error message ...drupal/theme_switcher 1.1.0 requires drupal/core ^8.5.... This module is incompatible with Drupal v9 (and maybe has been the cause for the very bad idea mentioned in earlier). Luckily there is now a drupal/theme_switcher:^1.2 which is compatible with Drupal v9.
  3. In my experience the most reliable way to update Drupal core is to explicitly require a new minimum version of core-recommended and core-composer-scaffold: composer require drupal/core-recommended:^9.2.4 drupal/core-composer-scaffold:^9.2.4 --update-with-dependencies.
  4. In your special case you also need to update the v8 Theme switcher module to get a full set of v9 compatible packages: composer require drupal/core-recommended:^9.2.4 drupal/core-composer-scaffold:^9.2.4 drupal/theme_switcher:^1.2 --update-with-dependencies
4
  • Unfortunately "drupal/core": "9.2.3 as 8.9.0" and friends is kind of sanctioned: drupal.org/docs/upgrading-drupal/…. They give it as an option and only call it less recommended rather than giving its proper title of avoid at all costs
    – Clive
    Aug 16, 2021 at 11:12
  • Thanks @Hudri. I've tried these steps, but am currently getting msg: - drupal/core-recommended 9.2.4 requires drupal/core 9.2.4 -> satisfiable by drupal/core[9.2.4] but these conflict with your requirements or minimum-stability. - Conclusion: remove drupal/core 9.2.3
    – BrettSh
    Aug 16, 2021 at 17:21
  • @BrettS try to include drupal/core:^9.2.4 in the "composer require", and "composer remove" if afterwards
    – Hudri
    Aug 16, 2021 at 20:24
  • Turns out one of my problems was several contrib modules that were locally patched for Drupal 9. These modules but were still only downloadable as Drupal 8. In spite of the fact that the info files stated "^8 || ^9" composer was throwing errors. So, I removed references to those modules from composer files and then I was able to run composer require 'drupal/core-recommended:^9.2.4' 'drupal/core-composer-scaffold:^9.2.4' --update-with-dependencies. Thanks @Hudri
    – BrettSh
    Aug 17, 2021 at 10:24
-1

You've locked drupal/core-recommended to version 9.1.5 in this line:

"drupal/core-recommended": "^9.1.5",

I believe you can fix this by running:

composer update drupal/core-recommended:^9.2. -W

Edit: Also, this doesn't look good to me, but I don't think it has anything to do with your problem:

    "drupal/core": "9.2.3 as 8.9.0",

I'm guessing someone did some aliasing for upgrade purposes or something. I think I'd try removing the as 8.9.0 from that.

5
  • 2
    NB! The caret notation "^9.1.5" doesn't lock the version - read getcomposer.org/doc/articles/versions.md - it just blocks upgrading to Drupal 10.
    – hansfn
    Aug 16, 2021 at 6:29
  • No, it's a locks it to the regex you've provided which states 'the version starting with the string 9.1.5', which essentially locks it to version 9.1.5, since no other versions will start with this unless the 9.1 branch got to 9.1.50 and so on.
    – Jaypan
    Aug 16, 2021 at 6:59
  • 2
    @Jaypan No, this is incorrect, the ^ has nothing to do with regex at all, it is a major version lock, as @hansfn mentioned. The rule you are describing is the tilde ~ version range. ^9.1.5 means >= 9.1.5 and < 10 while ~9.1.5 means >=9.1.5 and < 9.2
    – Hudri
    Aug 16, 2021 at 7:19
  • Ok, I stand corrected. Thanks.
    – Jaypan
    Aug 16, 2021 at 7:35
  • This could use better documentation, because you can get different results between ^9.0 vs ^9.2, same for modules, depending on dependency calculation. I just experienced this with a contributed module and was hard to spot because of the minor version causing it.
    – Kevin
    Aug 16, 2021 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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