Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yii2 composer update error: Invalid version string "2.*"

I'm use composer update in a Yii2 project, but it is exiting with an exception. I have updated composer to the lastest version, c6cc6dd6070871f4b198ed39f76dd8047c116b02, but it still doesn't work:

Importing tag v2.0.2 (2.0.2.0)
Reading bower.json of bower-asset/yii2-pjax (v2.0.1)
Reading /home/xiaoai/.composer/cache/repo/github.com/yiisoft/jquery-pjax/bower-f07ce95f6098c0bd5421789a20789f39a19be73b from cache
Importing tag v2.0.1 (2.0.1.0)
Reading /home/xiaoai/.composer/cache/repo/https---packagist.org/provider-yiisoft$yii2-bootstrap.json from cache
Reading /home/xiaoai/.composer/cache/repo/https---packagist.org/provider-bower-asset$bootstrap.json from cache
Downloading https://bower.herokuapp.com/packages/bootstrap
Writing /home/xiaoai/.composer/cache/repo/https---bower.herokuapp.com-packages/bootstrap-3c71cc99d2fc1c12a3d3e1b27e448ca612a89a1d-package.json into cache
Adding VCS repository bower-asset/bootstrap
Downloading https://api.github.com/repos/twbs/bootstrap
Downloading https://api.github.com/repos/twbs/bootstrap/contents/bower.json?ref=master
Downloading https://api.github.com/repos/twbs/bootstrap/commits/master
Downloading https://api.github.com/repos/twbs/bootstrap/tags?per_page=100
Downloading https://api.github.com/repos/twbs/bootstrap/git/refs/heads?per_page=100



  [UnexpectedValueException]                                              
  Could not parse version constraint <=2.*: Invalid version string "2.*"  

Exception trace:
 () at phar:///usr/bin/composer.phar/src/Composer/Package/Version/VersionParser.php:461
 Composer\Package\Version\VersionParser->parseConstraint() at phar:///usr/bin/composer.phar/src/Composer/Package/Version/VersionParser.php:257
 Composer\Package\Version\VersionParser->parseConstraints() at phar:///usr/bin/composer.phar/src/Composer/Package/Loader/ArrayLoader.php:234
 Composer\Package\Loader\ArrayLoader->parseLinks() at phar:///usr/bin/composer.phar/src/Composer/Package/Loader/ArrayLoader.php:123
 Composer\Package\Loader\ArrayLoader->load() at /home/xiaoai/.composer/vendor/fxp/composer-asset-plugin/Repository/AssetVcsRepository.php:174
 Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository->preInitBranchPackage() at /home/xiaoai/.composer/vendor/fxp/composer-asset-plugin/Repository/AssetVcsRepository.php:138
 Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository->initBranches() at /home/xiaoai/.composer/vendor/fxp/composer-asset-plugin/Repository/AssetVcsRepository.php:45
 Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository->initialize() at phar:///usr/bin/composer.phar/src/Composer/Repository/ArrayRepository.php:178
 Composer\Repository\ArrayRepository->getPackages() at phar:///usr/bin/composer.phar/src/Composer/DependencyResolver/Pool.php:104
 Composer\DependencyResolver\Pool->addRepository() at /home/xiaoai/.composer/vendor/fxp/composer-asset-plugin/Repository/Util.php:60
 Fxp\Composer\AssetPlugin\Repository\Util::addRepositoryInstance() at /home/xiaoai/.composer/vendor/fxp/composer-asset-plugin/Repository/Util.php:39
 Fxp\Composer\AssetPlugin\Repository\Util::addRepository() at /home/xiaoai/.composer/vendor/fxp/composer-asset-plugin/Repository/AbstractAssetsRepository.php:139
 Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository->whatProvides() at phar:///usr/bin/composer.phar/src/Composer/DependencyResolver/Pool.php:199
 Composer\DependencyResolver\Pool->computeWhatProvides() at phar:///usr/bin/composer.phar/src/Composer/DependencyResolver/Pool.php:188
 Composer\DependencyResolver\Pool->whatProvides() at phar:///usr/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php:161
 Composer\DependencyResolver\RuleSetGenerator->whitelistFromPackage() at phar:///usr/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php:273
 Composer\DependencyResolver\RuleSetGenerator->whitelistFromJobs() at phar:///usr/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php:324
 Composer\DependencyResolver\RuleSetGenerator->getRulesFor() at phar:///usr/bin/composer.phar/src/Composer/DependencyResolver/Solver.php:177
 Composer\DependencyResolver\Solver->solve() at phar:///usr/bin/composer.phar/src/Composer/Installer.php:505
 Composer\Installer->doInstall() at phar:///usr/bin/composer.phar/src/Composer/Installer.php:230
 Composer\Installer->run() at phar:///usr/bin/composer.phar/src/Composer/Command/UpdateCommand.php:140

I don't think this is my mistake, but how do I fix the exception?

like image 359
joaner Avatar asked Jul 28 '15 16:07

joaner


3 Answers

Michael Nguyen's answer did not work for me, but updating to dev-master did:

php composer.phar global require "fxp/composer-asset-plugin:dev-master"

One may also need to update composer itself:

php composer.phar self-update

Also there was an extensive discussion on this yesterday: link.

UPDATE. It seems to me at this moment "fxp/composer-asset-plugin:1.0.*@dev" is better again.

like image 95
Pavel Bariev Avatar answered Oct 22 '22 01:10

Pavel Bariev


I have the same issue and discussed on Yii Forum. It seems like this is a bug with "fxp/composer-asset-plugin".

Try

php composer.phar global require "fxp/composer-asset-plugin:1.0.1"

Then do whatever you need with composer

The bug is discussed at https://github.com/francoispluchino/composer-asset-plugin/issues/129

like image 21
Michael Nguyen Avatar answered Oct 22 '22 03:10

Michael Nguyen


It helped for me

composer self-update
composer global update
like image 27
Hett Avatar answered Oct 22 '22 01:10

Hett