Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alexleonard's avatar

Anyone else getting an odd composer update error today?

I started a fresh new laravel project last week and just came back to it to update a few things and make sure I'm keeping up with laravel/laravel develop commits.

First thing I did was composer update but this threw an error:

Could not load package phpspec/phpspec in http://packagist.org: [UnexpectedValueException] Could not parse version  constraint ^1.0.1: Invalid version string "^1.0.1"  

I did have phpspec/phpspec in my require-dev (although version ~2.1) so I commented that out of my composer.json and re ran composer update.

Sadly I still continued to receive the error.

I searched through my project for instances of phpspec/phpspec and none of them specify ^1.0.1 so I'm not really sure what's causing the error.

Anyone else getting this error on a composer update?

0 likes
12 replies
Youbility's avatar

Where did you try to run composer update? In Homestead or on your local machine? Have you tried composer selfupdate before composer update?

7 likes
yoyo001's avatar

you composer is over 30 days old? composer self-update

alexleonard's avatar

This is on my local machine, I haven't used homestead yet (I'm already in a virtual machine). Composer is up to date all right. Not getting composer errors on other projects either. Quite odd. Especially considering I can't see any mention of ^1.0.1 anywhere except my node_modules folder.

regattanetwork's avatar

I got a similar error when I tried to run composer update today. I got this message:

Loading composer repositories with package information
Updating dependencies (including require-dev)

  [RuntimeException]
  Could not load package anahkiasen/underscore-php in http://packagist.org: [ UnexpectedValueException] Could not parse version constraint ^4.2.16: Invalid version string "^4.2.16"

  [UnexpectedValueException]
  Could not parse version constraint ^4.2.16: Invalid version string "^4.2.16 "
darryldecode's avatar

I did first composer self-update and the problem is gone..

3 likes
alexleonard's avatar

Even though my composer wasn't out of date, it looks like a composer self-update was required.

Thanks @darryldecode

1 like
bliksem's avatar

Sorry for resurrecting this old topic, but I am also having this problem.

I did do a "composer self-update" and confirming that, I get this message:

$ composer self-update
You are already using composer version 5a5088eb342e4876cb28472ba1fc3f1da7a14852.

When I am trying to load the LaravelCollective/HTML package, by adding the following in my composer.json's require section:

"laravelcollective/html": "~5.1.*"

I get this error:

Could not parse version constraint ~5.1.*: Invalid version string "~5.1.*"

Any advice would be greatly appreciated. I am busy following the steps in a book, as I am brand new to Laravel (also have a Laracasts subscription) and I cannot continue with the book's steps until I have this issue resolved.

I am using Windows 10 64 bit, with XAMPP (with PHP 5.6) installed on a portable drive.

Thanks in advance!

Kobus

bliksem's avatar

I did, and it works, thanks. What would the implication of this be?

ohffs's avatar

@bliksem 5.1.* just means 5.1.anything :-) ~5.1 means "at least 5.1 but less than 6.0. ~5.1.2 means "at least 5.1.2 but less than 5.2.0" (ie, upto the next significant version given the number of digits in my sub-version). If that makes any sense ;-) There's lots more options too : https://getcomposer.org/doc/articles/versions.md

1 like

Please or to participate in this conversation.