Composer错误:UnexpectedValueException

时间:2017-02-17 09:23:11

标签: php laravel laravel-5 composer-php

我的作曲家突然停止了工作。我甚至没有添加新包,只是想检查一下,如果有任何更新:

PS C:\data\www\project.dev> composer self-update
You are already using composer version 1.3.2 (stable channel).

PS C:\data\www\project.dev> composer update
> php artisan clear-compiled
The compiled class file has been removed.
Loading composer repositories with package information
Updating dependencies (including require-dev)

  [UnexpectedValueException]
  Could not parse version constraint >=~2: Invalid version string "~2"


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]...

我到目前为止找到的所有解决方案都建议更新作曲家并检查composer.json,但不应该有任何错误:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.3.*",
        "edofre/laravel-fullcalendar-scheduler": "^1.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "5.0",
        "symfony/css-selector": "2.8.*|3.0.*",
        "symfony/dom-crawler": "2.8.*|3.0.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

正如你所看到的那样,没有什么特别之处。

PS:当然,我已经将thisthis混为一谈,但这些都是无关的问题。

1 个答案:

答案 0 :(得分:3)

编辑:

问题已在composer-asset-plugin的1.3.0@dev版本中修复。

可以通过以下方式安装:

composer global require fxp/composer-asset-plugin:~1.3@dev

另请参阅:https://github.com/fxpio/composer-asset-plugin/issues/270

我使用作曲家的详细输出来追踪你的问题。

问题最初是由要求

引起的
"edofre/laravel-fullcalendar-scheduler": "^1.0"

在此范围内需要一些bower包(为此我假设您安装了Composer Asset Plugin - 至少我必须按照laravel-fullcalendar-scheduler的文档中的说明进行操作)

其中一个凉亭包就是:

 "bower-asset/fullcalendar-scheduler": "v1.4.0"

Bower fullcalender-schedulare有一些依赖关系(在bower.json中):

 "dependencies": {
    "jquery": "2 - 3",
    "moment": "^2.9.0",
    "fullcalendar": "~3.2.0"
},

使用过的composer资产插件将jquery依赖项转换为:

">=~2,<4.0"

这最终会导致编辑器模块https://github.com/composer/semver中的错误引发错误 composer / semver / src / VersionParser.php:485

对于测试,我已手动将版本更改为&gt; = 2.0,这是有效的。

我目前还没有调查过,这是作曲家/ semver lib中的错误还是作曲家资产插件中的错误。

作曲家文档说~2是一个有效的版本号,但我不知道它是否应该用于比较,如&#34;&gt; ~2&#34; (在我的观点中,这根本没有意义......)