2

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.

Community
  • 1
  • 1
Peon
  • 7,902
  • 7
  • 59
  • 100
  • Is there any chance your composer.lock file contains the ~2.0 reference? – Joel Hinz Feb 17 '17 at 09:29
  • 1
    @JoelHinz the lock file should be overwritten on `update` isn't it? Any possibility that a package of your requirements has the `~2` in its require? – Pᴇʜ Feb 17 '17 at 09:41
  • There is no lock file, I already deleted it. But a dependency of a package is likely. Dunno how to check that though. – Peon Feb 17 '17 at 10:13
  • @Peh Ah, of course, I only saw the self-update. My bad! Hope you find the error, Dainis. – Joel Hinz Feb 17 '17 at 10:15
  • @DainisAbols try replacing your required dev section with ```"require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~4.0", "symfony/css-selector": "3.1.*", "symfony/dom-crawler": "3.1.*" },``` – Dev Feb 17 '17 at 10:58
  • @Dev the same error. I already trued removing the `2.8`. But also setting phpunit to 4, like you showed, didn't change anything. – Peon Feb 17 '17 at 11:17

1 Answers1

4

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

shock_gone_wild
  • 6,700
  • 4
  • 28
  • 52
  • This sounds correct, but where do I find (or create) the bower.json? I can't find and entry like `"jquery": "2 - 3",` nowhere :/ PS: so far I've tested, that this only occurs on my Windows DEV system. It works just fine on Ubuntu test and production server. – Peon Feb 17 '17 at 12:16
  • Solution didn't work for me. – smohadjer Apr 07 '22 at 07:33