composer 无法更新。Invalid version string "2.*"


yii2 使用 composer update ,到了 Adding VCS repository bower-asset/bootstrap 就报错


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

composer update -vvv 的报错开始于:


 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/local/bin/composer/src/Composer/Package/Version/VersionParser.php:461
 Composer\Package\Version\VersionParser->parseConstraint() at phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionParser.php:257
 Composer\Package\Version\VersionParser->parseConstraints() at phar:///usr/local/bin/composer/src/Composer/Package/Loader/ArrayLoader.php:234
 Composer\Package\Loader\ArrayLoader->parseLinks() at phar:///usr/local/bin/composer/src/Composer/Package/Loader/ArrayLoader.php:124
 Composer\Package\Loader\ArrayLoader->load() at /root/.composer/vendor/fxp/composer-asset-plugin/Repository/AssetVcsRepository.php:174
 Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository->preInitBranchPackage() at /root/.composer/vendor/fxp/composer-asset-plugin/Repository/AssetVcsRepository.php:138
 Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository->initBranches() at /root/.composer/vendor/fxp/composer-asset-plugin/Repository/AssetVcsRepository.php:45
 Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository->initialize() at phar:///usr/local/bin/composer/src/Composer/Repository/ArrayRepository.php:178
 Composer\Repository\ArrayRepository->getPackages() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Pool.php:104
 Composer\DependencyResolver\Pool->addRepository() at /root/.composer/vendor/fxp/composer-asset-plugin/Repository/Util.php:60
 Fxp\Composer\AssetPlugin\Repository\Util::addRepositoryInstance() at /root/.composer/vendor/fxp/composer-asset-plugin/Repository/Util.php:39
 Fxp\Composer\AssetPlugin\Repository\Util::addRepository() at /root/.composer/vendor/fxp/composer-asset-plugin/Repository/AbstractAssetsRepository.php:139
 Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository->whatProvides() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Pool.php:199
 Composer\DependencyResolver\Pool->computeWhatProvides() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Pool.php:188
 Composer\DependencyResolver\Pool->whatProvides() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php:161
 Composer\DependencyResolver\RuleSetGenerator->whitelistFromPackage() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php:273
 Composer\DependencyResolver\RuleSetGenerator->whitelistFromJobs() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php:324
 Composer\DependencyResolver\RuleSetGenerator->getRulesFor() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php:177
 Composer\DependencyResolver\Solver->solve() at phar:///usr/local/bin/composer/src/Composer/Installer.php:505
 Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:230
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:140
 Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:874
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:195
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:146
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:126
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:82
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
 require() at /usr/local/bin/composer:25


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [packages1] ... [packagesN]


[root@aliyun basic]#


/home/www/basic/composer.json 的全部内容:


 {
    "name": "yiisoft/yii2-app-basic",
    "description": "Yii 2 Basic Application Template",
    "keywords": ["yii2", "framework", "basic", "application template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "*",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "2amigos/yii2-ckeditor-widget": "*",
        "yiisoft/yii2-jui": "*",
        "2amigos/yii2-date-time-picker-widget": "~1.0",
        "hguenot/yii2-gftp": "*"
    },
    "require-dev": {
        "yiisoft/yii2-codeception": "*",
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-faker": "*"
    },
    "config": {
        "process-timeout": 1800
    },
    "scripts": {
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject"
        ]
    },
    "extra": {
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0755"
                }
            ],
            "generateCookieValidationKey": [
                "config/web.php"
            ]
        },
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }
}


@JellyBool 继续报错


 [root@aliyun ~]# composer  global require "fxp/composer-asset-plugin:1.0.1"
Changed current directory to /root/.composer
Deprecation Notice: Composer\Package\Version\VersionParser::parseLinks is deprecated. Use \Composer\Package\Loader\ArrayLoader::parseLinks() i
nstead in phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionParser.php:226
./composer.json has been updated
Deprecation Notice: Composer\Package\Version\VersionParser::parseLinks is deprecated. Use \Composer\Package\Loader\ArrayLoader::parseLinks() i
nstead in phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionParser.php:226
Loading composer repositories with package information
Updating dependencies (including require-dev)
^C
[root@aliyun ~]#


无法自动更新: composer self-update ,在linode上可以,在国内阿里云无法成功。


 [root@aliyun basic]# composer self-update
Updating to version bd2d7eba05dc6a51dbbad780b6f0eb505accba75.
    Downloading: 100%



  [Composer\Downloader\TransportException]
  The "https://getcomposer.org/composer.phar" file could not be downloaded: S
  SL: Connection reset by peer
  failed to open stream: HTTP request failed!



self-update [-r|--rollback] [--clean-backups] [--no-progress] [version]


[root@aliyun basic]#

阿里云直接使用 wget -c https://getcomposer.org/composer.phar ,一直在 443 那等待


 [root@aliyun ~]# wget -c https://getcomposer.org/composer.phar
--2015-08-02 15:52:30--  https://getcomposer.org/composer.phar
Resolving getcomposer.org (getcomposer.org)... 87.98.253.108, 2001:41d0:a:7b19::
1
Connecting to getcomposer.org (getcomposer.org)|87.98.253.108|:443...

composer php-composer yii2 阿里云

kofss 10 years ago

试试执行这个:


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

再不行就:


 composer self-update

Happy Hacking

超电磁炮第2季 answered 10 years ago

Your Answer