Problem/Motivation

I'm trying to use composer to update Drupal core to 9.4.4 but it's running into a problem when trying to fetch drupal/media:* as a dependency. This is preventing a Drupal core update unless I move the module out of composer.

Steps to reproduce

When I specifically require drupal/colorbox_media_video:^1.0 and drupal/core-recommended:9.4.4, I get a conflict that prevents composer from completing.

It can look different but here is a simple example when stability is set to alpha (we shouldn't need dev stability to install this):

  Problem 1
    - Root composer.json requires drupal/colorbox_media_video ^1.0 -> satisfiable by drupal/colorbox_media_video[1.0.0].
    - drupal/colorbox_media_video 1.0.0 requires drupal/media * -> found drupal/media[dev-1.x, 1.x-dev (alias of dev-1.x)] but it does not match your minimum-stability.

Here is what happens when stability is set to dev:

  Problem 1
    - drupal/media dev-1.x requires drupal/core ^8 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev] but it conflicts with your root composer.json require (9.4.4).
    - drupal/colorbox_media_video 1.0.0 requires drupal/media * -> satisfiable by drupal/media[dev-1.x, 1.x-dev (alias of dev-1.x)].
    - drupal/media 1.x-dev is an alias of drupal/media dev-1.x and thus requires it to be installed too.
    - Root composer.json requires drupal/colorbox_media_video ^1.0 -> satisfiable by drupal/colorbox_media_video[1.0.0].

Proposed resolution

Remove drupal/media:* as a composer requirement for the module. I think this may be left over from before media was in core. However, I can't tell if this is a bug with Drupal 9.4.4 or a change we need to live with.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

inversed created an issue. See original summary.

inversed’s picture

It looks like this is related to this change in 9.4.4: https://www.drupal.org/project/drupal/issues/3292380

inversed’s picture

With a little motivation from the folks in the Slack #support channel, I created fork with a composer.json file to solve this.

You can see the details here: https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...

Update your composer.json repositories section with the following:

        {
            "type": "composer",
            "url": "https://packages.drupal.org/8",
            "exclude": [
                "drupal/colorbox_media_video"
            ]
        },
        {
            "type": "package",
            "package": {
                "name": "drupal/colorbox_media_video",
                "version": "dev-1.0.x",
                "type": "drupal-module",
                "source": {
                    "type": "git",
                    "url": "git@git.drupal.org:issue/colorbox_media_video-3300783.git",
                    "reference": "1.0.x"
                }
            }
        }

Then, I ran the following:
composer require drupal/colorbox_media_video:dev-1.0.x

After that, I was able to update to Drupal 9.4.4.

mmjvb’s picture

Probably easier to add to your composer.json:
"provide": {
"drupal/media": "*"
},
to satisfy the requirement.

docker@cli:/var/www$ composer require drupal/colorbox_media_video --dry-run
Using version ^1.0 for drupal/colorbox_media_video
./composer.json has been updated
Running composer update drupal/colorbox_media_video
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 2 installs, 0 updates, 0 removals
  - Locking drupal/colorbox (1.10.0)
  - Locking drupal/colorbox_media_video (1.0.0)
Installing dependencies from lock file (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing drupal/colorbox (1.10.0)
  - Installing drupal/colorbox_media_video (1.0.0)
1 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.
Package webmozart/path-util is abandoned, you should avoid using it. Use symfony/filesystem instead.
96 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
docker@cli:/var/www$
inversed’s picture

@mmjb that's a great suggestion! For anyone looking for a quick fix to this sort of problem, the approach is definitely faster and smoother to implement. It's similar to the functionality that was removed from 9.4.4 (they removed "replace" which is similar to progress). I switched over to this approach as it makes it easier to deal with my deployment.

Long term, I hope the maintainer gets the composer.json file from this fork committed to a new release. Otherwise folks will start to find this module is incompatible with Drupal as time goes on. Additionally, adding the "provide" section means it's no longer possible to override that package without removing the workaround first. For drupal/media that's not likely to be an issue but it could be a problem for other packages that do get replaced from time to time.

inversed’s picture

mmjvb’s picture

Looks like they insist on making these kind of poor decisions and putting the blame on others.

It is recommended to qualify your dependencies. While not qualifying them worked in the past. They are now violating development according to semantic versioning by enforcing these recommendations. Thereby breaking what used to work.

Suggest to change dependencies in info.yml to use:
drupal:media
colorbox:colorbox

I am told that the facade will turn dependency on media into dependency on core. Consider that undesired, but it does keep composer happy depending on circumstances.

Wouldn't consider this a bug report, but will leave that to others.

spuky’s picture

Thanks #5 helped a lot

dadderley’s picture

Thank you mmjvb

Your solution in #5 worked for me

The addition of:

"provide": {
"drupal/media": "*"
},

to composer.json
Allowed me to up upgrade core from 9.4.3 to 9.4.5.

joelpittet made their first commit to this issue’s fork.

joelpittet’s picture

Status: Active » Needs review

Though I agree both the

"provide": {
"drupal/media": "*"
},

solution and the direct composer file (instead of the packaging one) would fix the issue, I think the simplest and most correct solution is @mmjvb mentioned in #8 #3300783-8: Composer conflict on drupal/media:* prevents Drupal 9.4.4 update

I created a new branch on this for that solution, though testing it would show the same results because the composer.json is not generated for the dev branch I wouldn't recommend testing that. I'd suggest the maintainer take a leap of faith... the solutions to similar problem are a not all the same so it's hard to compare but this should do the right thing.

mmjvb’s picture

It is indeed recommended to qualify dependencies by their project. Causes an issue when moving (to core or contrib). So, don't consider that the right way nor does the enforcing it this way is. Also consider manipulation by the facade wrong. Dependencies should be kept minimal, allowing providers and replacing.

Not having projects on drupal.org, wonder what happens to those that provide a composer.json. There are still people not understanding the difference between dependencies in info.yml and composer.json.

johnpicozzi’s picture

I had this issue and used the composer addition suggested (Comment #10) and I can also confirm it worked.

This project needs a composer.json, I have reached out to the maintainer via Drupal Slack to see if we can at least get that to resolve this issue. Not sure it will do any good, but worth a try.

If anyone here is interested in maintaining this module you could follow the process here https://www.drupal.org/docs/develop/managing-a-drupalorg-theme-module-or... to take over unsupported projects.

vacilando’s picture

Confirming that

"provide": {
  "drupal/media": "*"
},

is a perfect workaround here.
Without finding this we could not update Drupal core.

Is there a proper fix in the works?

goldin’s picture

Also confirming that #5 works. For those wondering exactly where to put it, I just added those lines to the very bottom of my site root composer.json file.

jeffc518’s picture

Thank you for this, I can also confirm #5 works. Until I specified a specific core version I wanted to update to, Composer wasn't giving me any clues with

composer update drupal/core 'drupal/core-*' --with-all-dependencies

.. it just wouldn't grab the latest core.

Then for giggles:

composer update drupal/core:9.4.8 'drupal/core-*':9.4.8 --with-all-dependencies

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

Problem 1
- drupal/colorbox_media_video is locked to version 1.0.0 and an update of this package was not requested.
- drupal/colorbox_media_video 1.0.0 requires drupal/media * -> found drupal/media[dev-1.x, 1.x-dev (alias of dev-1.x)] but it does not match your minimum-stability.

.. Finally some feedback : )

joelpittet’s picture

#5 is a workaround, maintainer please consider the MR.

  • tamerzg committed 8f41c53 on 1.0.x authored by inversed
    Issue #3300783: drupal/media should be removed from composer after...
tamerzg’s picture

Status: Needs review » Patch (to be ported)

Thanks everyone, I just made a 1.0.1 release. Beside adding composer.json I also had to prefix Media dependency in colorbox_media_video.info.yml

tamerzg’s picture

Status: Patch (to be ported) » Fixed
dadderley’s picture

This was a particularly nasty issue that was not easy to diagnose.
Grateful for the fix, but haven't tried it yet.

inversed’s picture

I think we can mark this one closed. Composer has no problems updating to the 1.0.1 release on Drupal 9.4.8 after removal of the workaround from #5.

joelpittet’s picture

@tamerzg could you also commit the https://git.drupalcode.org/issue/colorbox_media_video-3300783/-/compare/... fix to the formatting? You wouldn't have to maintain a composer.json if that was in place.

joelpittet’s picture

Version: 1.0.0 » 1.0.x-dev
tamerzg’s picture

@joelpittet drupal:media was already added in my previous commit
https://git.drupalcode.org/project/colorbox_media_video/-/blob/1.0.x/col...

and that seemed to fix the issue. I wasn't sure about composer.json which was also added in 1.1, but it seems I might remove it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.