Score:-2

Issues updating from 9.4.3 with composer

eg flag

I have a project that wasn't updated since a few months and I am stuck on 9.4.3 with composer refusing to update.

Here is my composer.json

{
    "name": "drupal-composer/drupal-project",
    "description": "Project template for Drupal 9 projects with Composer",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "authors": [
        {
            "name": "",
            "role": ""
        }
    ],
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "php": ">=7.3",
        "buzzingpixel/twig-switch": "^1.0",
        "composer/installers": "^1.9",
        "cweagans/composer-patches": "^1.7",
        "drupal/admin_toolbar": "^3.0",
        "drupal/auto_entitylabel": "^3.0@beta",
        "drupal/better_exposed_filters": "^5.0@beta",
        "drupal/better_social_sharing_buttons": "^3.2",
        "drupal/ckeditor_media_embed": "^1.11",
        "drupal/ckeditor_youtube": "^1.3",
        "drupal/components": "^2.2",
        "drupal/console": "~1.0",
        "drupal/core-composer-scaffold": "^9.1",
        "drupal/core-recommended": "^9.1",
        "drupal/devel": "^4.1",
        "drupal/editor_advanced_link": "^2.0",
        "drupal/eu_cookie_compliance": "^1.19",
        "drupal/fontawesome": "^2.18",
        "drupal/gin": "^3.0@beta",
        "drupal/gin_toolbar": "^1.0@beta",
        "drupal/google_analytics": "^4.0",
        "drupal/jquery_minicolors": "^1.3",
        "drupal/mailchimp": "^2.0",
        "drupal/migrate_plus": "^6.0",
        "drupal/migrate_source_csv": "^3.5",
        "drupal/migrate_tools": "^6.0",
        "drupal/paragraphs": "^1.12",
        "drupal/pathauto": "^1.8",
        "drupal/quick_node_clone": "^1.14",
        "drupal/rabbit_hole": "^1.0@beta",
        "drupal/radix": "^4.10",
        "drupal/recaptcha": "^3.0",
        "drupal/search_api": "^1.20",
        "drupal/search_api_db": "^1.20",
        "drupal/search_api_page": "^1.0@beta",
        "drupal/signature_field": "^2.1",
        "drupal/token": "^1.9",
        "drupal/views_bootstrap": "^4.3",
        "drupal/views_bulk_edit": "^2.5",
        "drupal/views_bulk_operations": "^4.1",
        "drupal/views_simple_math_field": "^3.0",
        "drupal/webform": "^6.0",
        "drupal/weight": "^3.3",
        "drush/drush": "^10.3",
        "kint-php/kint": "^3.3",
        "twig/twig": "2.15.2",
        "vlucas/phpdotenv": "^5.1",
        "webflo/drupal-finder": "^1.2"
    },
    "require-dev": {
        "drupal/core-dev": "^9.1",
        "zaporylie/composer-drupal-optimizations": "^1.2"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "discard-changes": true,
        "sort-packages": true,
        "allow-plugins": {
            "composer/installers": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "drupal/console-extend-plugin": true,
            "cweagans/composer-patches": true,
            "drupal/core-composer-scaffold": true,
            "zaporylie/composer-drupal-optimizations": true
        }
    },
    "autoload": {
        "classmap": [
            "scripts/composer/ScriptHandler.php"
        ],
        "files": [
            "load.environment.php"
        ]
    },
    "scripts": {
        "pre-install-cmd": [
            "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
        ],
        "pre-update-cmd": [
            "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
        ],
        "post-install-cmd": [
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
        ],
        "post-update-cmd": [
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
        ]
    },
    "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"
            ]
        },
        "composer-exit-on-patch-failure": true,
        "patchLevel": {
            "drupal/core": "-p2"
        },
        "patches": {
            "drupal/devel": {
                "Brings back the Available Methods & Properties tabs for Kint dumps — Issue #221": "https://raw.githubusercontent.com/politsin/snipets/master/patch/kint.patch"
            },
            "drupal/better_exposed_filters": {
                "Fix error with exposed filters arguments": "https://www.drupal.org/files/issues/2020-09-18/3159875-8.patch"
            },
            "drupal/better_social_sharing_buttons": {
                "HTMLSpecialChars error on login page": "https://www.drupal.org/files/issues/2021-06-22/3216304-4.patch"
            },
            "drupal/search_api_page":  {
                "PHP 8.1 strpos() error": "https://www.drupal.org/files/issues/2022-05-31/3274050-4-php-8-warning-pathprocessorsearchapipage.patch"
            }
        }
    }
}

If I run the following, it just doesn't update anything.

$ composer update "drupal/core-*" --with-all-dependencies

So I tried:

$ composer why-not drupal/core 9.4.12
drupal/core-recommended  9.4.3  requires  drupal/core (9.4.3) 

And also:

$ composer prohibits drupal/core-recommended 9.4.5
drupal/core-recommended         9.4.5        requires          drupal/core (9.4.5)                   
drupal-composer/drupal-project  dev-develop  does not require  drupal/core (but 9.4.3 is installed)

And also with 9.5.7 which is the recommended version I see from the admin:

$ composer prohibits drupal/core-recommended 9.5.7
drupal/core-recommended         9.5.7        requires          drupal/core (9.5.7)                                          
drupal-composer/drupal-project  dev-develop  does not require  drupal/core (but 9.4.3 is installed)                         
drupal/core-recommended         9.5.7        requires          laminas/laminas-diactoros (~2.14.0)                          
drupal-composer/drupal-project  dev-develop  does not require  laminas/laminas-diactoros (but 2.11.3 is installed)          
drupal/core-recommended         9.5.7        requires          laminas/laminas-stdlib (~3.11.0)                             
drupal-composer/drupal-project  dev-develop  does not require  laminas/laminas-stdlib (but 3.7.1 is installed)              
drupal/core-recommended         9.5.7        requires          symfony/polyfill-ctype (~v1.27.0)                            
drupal-composer/drupal-project  dev-develop  does not require  symfony/polyfill-ctype (but v1.25.0 is installed)            
drupal/core-recommended         9.5.7        requires          symfony/polyfill-iconv (~v1.27.0)                            
drupal-composer/drupal-project  dev-develop  does not require  symfony/polyfill-iconv (but v1.25.0 is installed)            
drupal/core-recommended         9.5.7        requires          symfony/polyfill-intl-idn (~v1.27.0)                         
drupal-composer/drupal-project  dev-develop  does not require  symfony/polyfill-intl-idn (but v1.25.0 is installed)         
drupal/core-recommended         9.5.7        requires          symfony/polyfill-intl-normalizer (~v1.27.0)                  
drupal-composer/drupal-project  dev-develop  does not require  symfony/polyfill-intl-normalizer (but v1.25.0 is installed)  
drupal/core-recommended         9.5.7        requires          symfony/polyfill-mbstring (~v1.27.0)                         
drupal-composer/drupal-project  dev-develop  does not require  symfony/polyfill-mbstring (but v1.25.0 is installed)         
drupal/core-recommended         9.5.7        requires          symfony/polyfill-php80 (~v1.27.0)                            
drupal-composer/drupal-project  dev-develop  does not require  symfony/polyfill-php80 (but v1.25.0 is installed)            
drupal/core-recommended         9.5.7        requires          twig/twig (~v2.15.4)                                         
drupal-composer/drupal-project  dev-develop  requires          twig/twig (2.15.2) 

Any idea what is going on? I am having a hard time figuring out what prevents the update.

4uk4 avatar
cn flag
I think it's not a good idea to post an entire composer.json before it was cleaned up. For example, why did you pin twig/twig to a specific version, why you still need aporylie/composer-drupal-optimizations, are all beta versions still maintained?
MrUpsidown avatar
eg flag
@4uk4 Thanks for the feedback. I had to require that specific Twig version because of an issue with one of the themes (Claro). I have disabled the theme now and removed Twig but still no luck.
Score:2
ne flag

As soon as you remove twig/twig from your composer.json it will work.

$ composer remove twig/twig --no-update
$ composer update "drupal/core-*" --with-all-dependencies

(You then need to update the patches, but that's a different issue. Also move drupal/devel and kint-php/kint to require-dev, this should never land on prod. Aaand you should also update your PHP and update the PHP requirement in the composer.json then.)

MrUpsidown avatar
eg flag
Thanks but still no luck. I am on PHP 8.1.9 now, and updated the PHP requirement to `"php": "^7.3||^8.0"` but running the composer update leads to *Nothing to install, update or remove*.
leymannx avatar
ne flag
@MrUpsidown – I used your composer.json when trying. There must be errors that are different than `no luck` . Please update your question with the progress.
cn flag
Unless you're comfortable working through this stuff yourself, it's probably best to bite the bullet, delete composer.lock, run composer install, and deal with testing the changes to any contrib module updates that result. Trying to debug and work through this in a back-and-forth in the comments here isn't likely to get anyone a useful a result
MrUpsidown avatar
eg flag
Hi, yes, I agree. I am still on it and still haven't found what the issue is but it's difficult to update my question with all my attempts. I undesrtand it's not a great question and it's hard to deal with it. I'll try what @Clive suggested. I have tried replacing the modules that are in beta but so far no progress.
MrUpsidown avatar
eg flag
Oh boy! Thanks @Clive, that actually did the trick. I deleted the lock file, ran `composer install` and it locked all modules, upgraded what needed to be upgraded, including `Upgrading drupal/core-recommended (9.4.3 => 9.5.7)` and all seems fine! If you wish to provide this as an answer, feel free! Thanks
4uk4 avatar
cn flag
Most times a simple `composer update` will do the trick, too. After of course, you've resolved the main problem, the twig/twig version @leymannx successfully reproduced, and after removing all outdated packages.
cn flag
@MrUpsidown Glad you got it sorted :) I'd tend to agree with 4k4, the strict answer to the question is what leymannx has provided here - composer install/update is kind of Composer's equivalent of Drupal's "clear the cache"
MrUpsidown avatar
eg flag
All right. Thanks everyone for your help!
I sit in a Tesla and translated this thread with Ai:

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.