Search code examples
phpcodeigniterpackagecomposer-php

Failed while installing a package using composer


iam tryin to use a cart package by using this command

composer require jason-napolitano/codeigniter4-cart-module

and it's failed. this is what it said

Using version dev-master for jason-napolitano/codeigniter4-cart-module
./composer.json has been updated
Running composer update jason-napolitano/codeigniter4-cart-module
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires jason-napolitano/codeigniter4-cart-module dev-master -> satisfiable by jason-napolitano/codeigniter4-cart-module[dev-master].
    - jason-napolitano/codeigniter4-cart-module dev-master requires codeigniter4/framework ^4.0.3 -> satisfiable by codeigniter4/framework[v4.0.3, ..., v4.1.1] from composer repo (https://repo.packagist.org) but codeigniter4/framework[1.0.0+no-version-set] from root package repo has higher repository priority. The
packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

is it because my minimum-stability in composer.json is set to "stable"?


Solution

  • I presume you created your project by using composer create-project codeigniter4/framework. This effectively created a clean project for you without the .git folder, thus removing any metadata on what version of codeigniter4/framework package you installed. This is indicative by 1.0.0+no-version-set part of the error message.

    The jason-napolitano/codeigniter4-cart-module package requires ^4.0.3 version of codeigniter4/framework, but since you have no version metadata in your project, install fails. This can be resolved by setting the version from which you bootstrapped your project manually in your root composer.json:

    {
        "name": "codeigniter4/framework",
        "version": "4.0.3",
        ...
    }
    

    However, this is just a guess, since I have no insight into your main composer.json.