Problem/Motivation

When you require a dev release of something, e.g. with composer require drupal/modulename:1.0.x-dev then the unpack plugin fails with an error message "drupal/modulename does not resolve to a package." and quits.

When requiring with a proper constraint, e.g. composer require drupal/modulename:^1.0, then there is no error, even if only the dev release is available and gets downloaded.

Steps to reproduce

composer create-project drupal/recommended-project:^11 recipe-test
composer require drupal/eca drupal/bpmn_io
composer require drupal/eca:3.0.x-dev drupal/bpmn_io:3.0.x-dev drupal/modeler_api:1.0.x-dev

Proposed resolution

drupal/eca:3.0.x-dev causes $package to be an \Composer\Package\AliasPackage not what the code expects \Composer\Package\Package. We need to use \Composer\Package\PackageInterface instead.

Remaining tasks

User interface changes

None

Introduced terminology

N/a

API changes

None

Data model changes

None

Release notes snippet

N/a

Issue fork drupal-3532796

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

jurgenhaas created an issue. See original summary.

alexpott’s picture

Can you add your actual steps to reproduce this issue. I cannot reproduce this. Here's the output of composer --version for me...

Composer version 2.7.7 2024-06-10 22:11:12
PHP version 8.3.21 (/opt/homebrew/Cellar/php@8.3/8.3.21/bin/php)

Here's what I'm doing:

composer create-project drupal/recommended-project:^11 recipe-test
composer require drupal/events:1.0.x-dev
composer require drupal/inline_translation:1.x-dev
composer require drupal/eca:3.0.x-dev drupal/modeler_api:1.0.x-dev

The events recipe is successfully unpacked and the modules are installed. No messages from the recipe plugin.

I've also updated to composer 2.7.7 and it does not happen for that version either.

alexpott credited rkoller.

alexpott’s picture

Steps to reproduce from @rkoller

composer create-project drupal/recommended-project:^11 recipe-test
composer require drupal/eca drupal/bpmn_io
composer require drupal/eca:3.0.x-dev drupal/bpmn_io:3.0.x-dev drupal/modeler_api:1.0.x-dev

On the second require you will see drupal/eca does not resolve to a package. in the output.

alexpott’s picture

Issue summary: View changes
Status: Active » Needs review

alexpott’s picture

I've tried to write a test for this but it is hard - I can;t get composer to use an alias for our path repositories used in testing.

I've now got even less steps to cause the problem

composer create-project drupal/recommended-project:^11 recipe-test
cd recipe-test
composer require "drupal/inline_translation:1.x-dev as 1.0.0"

But doing $this->runComposer('require "fixtures/module-b:2.0.1 as 3.0.0"') in a \Drupal\Tests\Composer\Plugin\Unpack\Functional\UnpackRecipeTest does not cause the problem :(

jurgenhaas’s picture

Status: Needs review » Reviewed & tested by the community

I've tested this successfully. With the commands from #7 I wasn't able to reproduce the issue, but the following showed the error:

composer create-project drupal/recommended-project:^11 recipe-test
cd recipe-test
composer require drupal/eca # <= This installs version 2.0
composer require drupal/eca:3.0.x-dev drupal/modeler_api:1.0.x-dev # <= This shows the expected error

Then I tried again and patched with this MR first. Then the error was gone.

  • catch committed 50cbe65c on 11.2.x
    Issue #3532796 by alexpott, jurgenhaas, rkoller: Composer unpack plugin...

  • catch committed a38e8d0f on 11.x
    Issue #3532796 by alexpott, jurgenhaas, rkoller: Composer unpack plugin...
catch’s picture

Version: 11.x-dev » 11.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 11.2.x, thanks!

Status: Fixed » Closed (fixed)

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