Problems with Composer 2 and bower asset

So, Composer updated to version 2 and broke our CI. :slight_smile: Anyone found a solution to this? Locally I’m using PHP 7.4 and Composer 2.

This command:

./composer.phar require yidas/yii2-bower-asset

Fails with:

  Problem 1
    - fxp/composer-asset-plugin[v1.2.2, ..., v1.4.6] require composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
    - Root composer.json requires fxp/composer-asset-plugin ^1.2.2 -> satisfiable by fxp/composer-asset-plugin[v1.2.2, ..., v1.4.6].

You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.

Running:

./composer.phar update

fails with:

The "fxp/composer-asset-plugin" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.                                                                                                                        
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - yiisoft/yii2 2.0.35 requires bower-asset/jquery 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable -> found bower-asset/jquery[3.5.1] but it does not match the constraint.
    - yiisoft/yii2[2.0.36, ..., 2.0.38] require bower-asset/jquery 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable -> found bower-asset/jquery[3.5.1] in lock file but not in remote repositories, make sure you avoid updating this package to keep the one from lock file.
    - Root composer.json requires yiisoft/yii2 >=2.0.35 -> satisfiable by yiisoft/yii2[2.0.35, 2.0.36, 2.0.37, 2.0.38].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Ideas?

How about switching to asset packagist like we did years ago in Yii 2 application templates?

5 Likes

The asset-plugin is not available for composer 2.0 yet.

Still not working with composer 2.0 - what helped here:
Use

composer self-update --rollback

to return to version 1.10.8 (or whatever).

Has anyone found a solution?

Of course, Problems with Composer 2 and bower asset

The main problem of this case i cant override bower repo using myself.
fxp/composer-asset-plugin support this
“asset-repositories”: […]

What is the change related to this yii2-app-basic/web.php at master · yiisoft/yii2-app-basic · GitHub in advanced app?

Thanks

That’s changing composer fxp plugin to https://asset-packagist.org/

Is it needed composer-asset-plugin at all or may we change to fxpio/foxy?

None of these are needed. See how it’s done in current basic template of Yii 2.

@samdark Small Suggestion - Please update advanced app configurations in your answer as well. It will useful for others - yii2-app-advanced/main.php at master · yiisoft/yii2-app-advanced · GitHub

1 Like