Create project with composer fails with unclear error

Hi there,

The following command fails:
composer create-project roots/sage your-theme-name dev-main

The error is the following.
Could not find package roots/sage with version dev-main in a version installable using your PHP version, PHP extensions and Composer version.

Running php -v yields PHP 7.3.29, which is fine according to the version 9 docs, although for version 10 I can’t find a compatibility list.

I’m using composer 2.1.8.

My best guess is I am missing some PHP extension, but the error doesn’t specify whether the issue is PHP, an extension, or composer.

Is there a way to find out?

What about the error is unclear? It’s telling you a package (roots/sage) is not compatible with your PHP Version, PHP extensions, or Composer version. The first step to determining which of these things is the problem would be to example the requirements for the package you’re attempting to install. The composer.json for sage specifies the PHP requirement:

 "require": {
    "php": "^7.4|^8.0"
  },

Your version (7.3) doesn’t meet that requirement.

@alwaysblank thanks for pointing me to this file! I’ll start by upgrading my PHP version.

Does the composer.json file also specify the PHP extensions needed and/or which composer version is needed? Or is this specified elsewhere?

I find this error unclear for the following reasons:

  1. It doesn’t specify what any of the requirements are (which PHP version, for example)
  2. It doesn’t specify which of the three requirements has not been met
  3. It doesn’t specify whether multiple requirements have not been met (i.e. will fixing the PHP version be enough, or are there more things to fix)

Hope this feedback is helpful to you.

Please consider that I am in this case copying the first command from the getting started guide webpage, which makes no reference to the composer.json file you link to and which also doesn’t actually seem to list the requirements. At least it is not under “compatibility”.

For anyone following the guide, it’s really not obvious that you should first locate the github page and review a JSON file :slight_smile:

Thanks for the additional information! The docs are always a work in progress, and we welcome PRs to help improve them.

In the case of this particular error, there isn’t a great deal we (the Roots team) can do about it, as the error is generated by Composer and isn’t something we can modify. If you’re not familiar with Composer, their docs are pretty good and explain how Composer works and how to troubleshoot problems with it.

I didn’t realise the message was completely generated by Composer. That’s a bummer, it could benefit from being clearer.

I’m marking as resolved, let’s hope upgrading PHP solves this issue for me next time.