updating – How do I install and patch a module with composer, when the version dependencies need changing?

A patch that changes version dependencies


 package: Commerce (contrib)
 type: module
 core: 8.x
 +core_version_requirement: ^8 || ^9

Apply the patch in composer.json

"extra": {
    "enable-patching": true,
    "patches": {
        "drupal/commerce_autosku": {
            "d9 compatibility": "src/patches/patch-for-d9-3150280--5.patch"

Race condition

Updating dependencies                                 
Your requirements could not be resolved to an installable set of packages.

Problem 1
- drupal/commerce_autosku dev-2.x requires drupal/core ~8.0 -> found drupal/core(8.0.0-beta6, ..., 8.9.x-dev) but the package is fixed to 9.2.4 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.