Peon
Peon

Reputation: 8030

Composer error: UnexpectedValueException

My composer suddenly stopped working. I didn't even add new packages, just wanted to check, if there are any updates:

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]...

All solutions I found so far suggested to update composer and check the composer.json, but there shouldn't nu anything wrong in there:

{
    "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"
    }
}

As you can see, there is nothing special in there.

PS: Of course, I already chkecked this and this, but those are unrelated problems.

Upvotes: 2

Views: 7322

Answers (1)

shock_gone_wild
shock_gone_wild

Reputation: 6740

EDIT:

The Problem is fixed in the 1.3.0@dev version of the composer-asset-plugin.

It can be installed via:

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

See also: https://github.com/fxpio/composer-asset-plugin/issues/270


I have tracked down your problem using the verbose output of composer.

The problem is initially caused by requiring

"edofre/laravel-fullcalendar-scheduler": "^1.0"

Within this some bower packages are required ( For this I assume you installed Composer Asset Plugin -at least I had to do this as stated in the docs of laravel-fullcalendar-scheduler)

One of these bower packages is for example:

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

The Bower fullcalender-schedulare has some dependencies ( in bower.json):

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

The used composer asset plugin translates the jquery dependency to:

">=~2,<4.0"

This finally causes the error in the composer module https://github.com/composer/semver which raises an error composer/semver/src/VersionParser.php:485

For testing i have manually changed the version to >=2.0 which is working.

I currently have not investigated wheter this is a bug in the composer/semver lib or a bug in the composer asset plugin.

The composer docs say that ~2 is a valid version number, but I don't know if it is supposed to be used in comparisons like ">~2" ( in my oppionion this makes no sense at all... )

Upvotes: 4

Related Questions