Solution

Composer 1.10.11 has a bug. Use a newer version of Composer.

Original Report

Problem/Motivation

I'm trying to update drupal/core 8.9.3 -> 8.9.5. When using the command 'composer update', I get the following errors:

  [RuntimeException]
  Could not load package ezsystems/ezplatform in http://repo.packagist.org: [UnexpectedValueException] Could not parse version constraint dev-load-varnish-only-when-used as ^2.0@dev: Invalid version string "^2.0@dev"

  [UnexpectedValueException]
  Could not parse version constraint dev-load-varnish-only-when-used as ^2.0@dev: Invalid version string "^2.0@dev"

I'm not a developer, sorry for any incorrectness. How can I fix that?

Comments

quicktrick created an issue. See original summary.

cilefen’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

Hello @quicktrick

ezsystems/ezplatform isn't part of Drupal Core. I recommend providing the composer.json file in case someone from the Drupal community wishes to help.

jonathan1055’s picture

I have the same problem - see https://travis-ci.org/github/jonathan1055/scheduler/builds/725297776
It started around 15:00 UTC today

sandervanhooft’s picture

Same problem here, problem started occurring just now.

See related Travis build.

Tim Bozeman’s picture

Me too. Weird...

minorOffense’s picture

Same here. Two sites so far (d7 and d8) have failures because of this.

I think it might have to do with drupal/coder since that's the only project we have that's shared between the two sites. But I haven't actually confirmed that.

Neograph734’s picture

It appears to be coming from composer 1.10.11. Rolling back to 1.10.10 makes the issue go away.

Was already reported in Composer's github repo: https://github.com/composer/composer/issues/9191

sandervanhooft’s picture

jonathan1055’s picture

@minorOffense " think it might have to do with drupal/coder since that's the only project we have that's shared between the two sites."
I think it is nothing to do with Coder, but 3rd party software, not directly under Drupal control. See the link in #7 above

cilefen’s picture

Try composer why -r ezsystems/ezplatform

cilefen’s picture

Title: Composer "Could not parse version constraint dev-load-varnish-only-when-used as ^2.0@dev" » [upstream] Composer "Could not parse version constraint dev-load-varnish-only-when-used as ^2.0@dev"
Status: Postponed (maintainer needs more info) » Active
kunalkursija’s picture

I am using Drupal 9.0.3 and I Faced this issue after updating the composer to '1.10.11'.

Rolled back composer version as per #7 and the issue went away.

@jonathan1055 Even I was doing composer require drupal/coder right after updating the composer version. So after reading your comment, I tried composer require for other modules - But the issue remained on composer version `1.10.11`. I agree it looks like a Non-Drupal issue.

joelpittet’s picture

composer why -r ezsystems/ezplatform

  [InvalidArgumentException]
  Could not find package "ezsystems/ezplatform" in your project
jonathan1055’s picture

composer self-update 1.10.10 seems to fix it

kunalkursija’s picture

+1 to #14

fixator1’s picture

work after command: composer self-update --preview

kunalkursija’s picture

A new composer version has been released to fix this - https://github.com/composer/composer/issues/9191#issuecomment-689135410.

just tried it, composer self-update is updating to 1.10.12 and composer errors related to ezsystems/ezplatform are now gone.

cilefen’s picture

Issue summary: View changes
Status: Active » Fixed
sholanryu81’s picture

I'm on composer 1.10.12 and am still getting this error

I updated to composer 2.0.0-alpha3 and still get the error also.

cilefen’s picture

Status: Fixed » Active

@sholanryu81 What is the output of composer why composer/semver?

pingers’s picture

Anybody’s picture

For me it's still broken under 1.10.13 ... unsure why.

composer why composer/semver says:

composer/composer 1.10.10 requires composer/semver (^1.0)
drupal-composer/drupal-scaffold 2.6.1 requires composer/semver (^1.4)
drupal/core 8.9.3 requires composer/semver (^1.0)
drush/drush 9.7.2 requires composer/semver (^1.4)

cilefen’s picture

@Anybody. Same here with 1.10.13, except for me it's just some module in the site with a 'dev' dependency:

  [RuntimeException]
  Could not load package drupal/recaptcha in https://packages.drupal.org/8: [UnexpectedValueException] Could not parse version constraint dev: Invalid version string "dev"



  [UnexpectedValueException]
  Could not parse version constraint dev: Invalid version string "dev"

All I've been able to do is downgrade Composer like in #14. I am concerned this is going to blow up into a bigger issue. The reason I asked about `composer why` is that I don't know to what extent (if any) the version of composer/semver installed in the site can affect this. This is happening only on a Drupal codebase, which happens to have composer/semver 1.5.1. This could be a red herring so treat this information appropriately.

RGonski’s picture

I have the same issue as #23. Have tried updating, regressing to earlier versions.

[RuntimeException]
Could not load package drupal/recaptcha in https://packages.drupal.org/8: [UnexpectedValueException] Could not parse version constraint dev: Invalid version string "dev"
[UnexpectedValueException]
Could not parse version constraint dev: Invalid version string "dev"

cilefen’s picture

Here is a minimal reproducer:

{
    "name": "example/example",
    "type": "project",
    "license": "proprietary",
    "require": {
        "drupal/recaptcha": "^2.4"
       
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ]
}

Try composer update with Composer 1.10.13 against the composer.json file above in an empty directory.

cilefen’s picture

Mixologic’s picture

Title: [upstream] Composer "Could not parse version constraint dev-load-varnish-only-when-used as ^2.0@dev" » Validate version strings for composer.json
Project: Drupal core » packages.drupal.org
Version: 8.9.x-dev » 7.x-1.x-dev
Component: base system » Code
Assigned: Unassigned » Mixologic
Category: Support request » Bug report

Upstream has fixed most of the issues with this, yet there are still a few invalid versions in packages.drupal.org that we should catch and prevent from putting up to the facade.

jcnventura’s picture

Can we fix packages.drupal.org to remove this problem? It seems the issue is that this should not be allowed:

  "require": {
    "drupal/captcha": "dev"
  }

This is version 8.x-2.0 of the recaptcha module, and apparently only in that version. It may be that recaptcha is just one of many modules with broken versions in drupal.org, and since composer is not going to fix it, it should be fixed in packages. I think that ignoring any requires that are not correct should be enough. It will also serve to educate module maintainers when their requirements are ignored by composer.

jcnventura’s picture

Not sure which other issue is being used for this, but it seems that d.o has now fixed packages.d.o?

https://github.com/composer/composer/issues/9201

@Mixologic?

drumm’s picture

Status: Active » Fixed

Yes, Mixologic fixed this with https://bitbucket.org/drupalorg-infrastructure/drupal.org/commits/11baee..., which updates our dependency on composer used to validate composer.json files.

Mixologic’s picture

Yep. This is fixed. I still need to re-run the metadata generation on all the other projects to capture any other problems with rarer projects.

TrevorBradley’s picture

If anyone is *still* hitting this, try deleting your vendor directory and running "composer update" again.

alison’s picture

Are you saying we should downgrade composer and then if the problem still happens, remove vendor dir and run again? (I removed vendor directory and tried running composer update again, without luck, so far -- also ran composer clear-cache.)

Mixologic’s picture

We're re-running the metadata currently (it takes about 3 days to reconstruct *all* of it), so there may still be some edge cases floating around.

@alisonjo315 it might be that you're encountering a different problem ?

Downgrading composer is first step if there are any issues. Then, once you have downgraded, your composer commands should run, and clear out any bad versions in the cache or vendor. Then you can upgrade composer again.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.