Emmajiugo
Emmajiugo

Reputation: 213

Composer Issues when trying to install a package globally

I uploaded a package to packagist, and ran this command to require it globally:

composer global require emmajiugo/flutterwave-cli

This failed with the following output:

Changed current directory to /Users/emmanuelezejiugo/.composer
Using version ^1.3 for emmajiugo/flutterwave-cli
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for emmajiugo/flutterwave-cli ^1.3 -> satisfiable by emmajiugo/flutterwave-cli[v1.3].
    - Conclusion: remove illuminate/container v5.8.28
    - Conclusion: don't install illuminate/container v5.8.28
    - emmajiugo/flutterwave-cli v1.3 requires laravel-zero/framework ^7.0 -> satisfiable by laravel-zero/framework[v7.0.0, v7.1.0, v7.2.0, v7.2.1].
    - laravel-zero/framework v7.0.0 requires illuminate/container ^7.0 -> satisfiable by illuminate/container[v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0, v7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.18.0, v7.19.0, v7.19.1, v7.2.0, v7.2.1, v7.2.2, v7.20.0, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
    - laravel-zero/framework v7.1.0 requires illuminate/container ^7.0 -> satisfiable by illuminate/container[v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0, v7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.18.0, v7.19.0, v7.19.1, v7.2.0, v7.2.1, v7.2.2, v7.20.0, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
    - laravel-zero/framework v7.2.0 requires illuminate/container ^7.0 -> satisfiable by illuminate/container[v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0, v7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.18.0, v7.19.0, v7.19.1, v7.2.0, v7.2.1, v7.2.2, v7.20.0, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
    - laravel-zero/framework v7.2.1 requires illuminate/container ^7.0 -> satisfiable by illuminate/container[v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0, v7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.18.0, v7.19.0, v7.19.1, v7.2.0, v7.2.1, v7.2.2, v7.20.0, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
    - Can only install one of: illuminate/container[v7.0.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.0.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.0.2, v5.8.28].
    - Can only install one of: illuminate/container[v7.0.3, v5.8.28].
    - Can only install one of: illuminate/container[v7.0.4, v5.8.28].
    - Can only install one of: illuminate/container[v7.0.5, v5.8.28].
    - Can only install one of: illuminate/container[v7.0.6, v5.8.28].
    - Can only install one of: illuminate/container[v7.0.7, v5.8.28].
    - Can only install one of: illuminate/container[v7.0.8, v5.8.28].
    - Can only install one of: illuminate/container[v7.1.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.1.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.1.2, v5.8.28].
    - Can only install one of: illuminate/container[v7.1.3, v5.8.28].
    - Can only install one of: illuminate/container[v7.10.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.10.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.10.2, v5.8.28].
    - Can only install one of: illuminate/container[v7.10.3, v5.8.28].
    - Can only install one of: illuminate/container[v7.11.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.12.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.13.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.14.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.14.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.15.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.16.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.16.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.17.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.17.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.17.2, v5.8.28].
    - Can only install one of: illuminate/container[v7.18.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.19.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.19.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.2.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.2.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.2.2, v5.8.28].
    - Can only install one of: illuminate/container[v7.20.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.3.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.4.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.5.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.5.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.5.2, v5.8.28].
    - Can only install one of: illuminate/container[v7.6.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.6.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.6.2, v5.8.28].
    - Can only install one of: illuminate/container[v7.7.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.7.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.8.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.8.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.9.0, v5.8.28].
    - Can only install one of: illuminate/container[v7.9.1, v5.8.28].
    - Can only install one of: illuminate/container[v7.9.2, v5.8.28].
    - Installation request for illuminate/container (locked at v5.8.28) -> satisfiable by illuminate/container[v5.8.28].


Installation failed, reverting ./composer.json to its original content.

I have tried changing a few things on my composer.json file and still getting the issue. Below is my composer.json file:

{
    "name": "emmajiugo/flutterwave-cli",
    "description": "A CLI app that helps you test Flutterwave payment on the go and also generate sample apps.",
    "keywords": ["framework", "flutterwave", "rave", "rave cli", "flutterwave cli", "rave console", "flutterwave console", "cli"],
    "homepage": "https://flutterwave.com",
    "type": "project",
    "license": "MIT",
    "support": {
        "issues": "https://github.com/emmajiugo/flutterwave-cli/issues",
        "source": "https://github.com/emmajiugo/flutterwave-cli"
    },
    "authors": [
        {
            "name": "Chigbo Ezejiugo",
            "email": "[email protected]"
        }
    ],
    "require": {
        "php": "^7.2.5",
        "laminas/laminas-text": "^2.7",
        "laravel-zero/framework": "^5.8",
        "padraic/phar-updater": "^1.0.6",
        "vlucas/phpdotenv": "^4.0",
        "yuloh/open": "^0.1.0"
    },
    "require-dev": {
        "mockery/mockery": "^1.3.1",
        "phpunit/phpunit": "^8.5"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "scripts": {
        "post-create-project-cmd": [
            "@php application app:rename"
        ]
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "bin": ["flutterwave"]
}

Upvotes: 0

Views: 779

Answers (3)

Emmajiugo
Emmajiugo

Reputation: 213

Thanks all.

I ran composer global update and it updated all the required packages. Then did composer global require repo-name/repo-package-name and it worked fine.

Upvotes: 0

IMSoP
IMSoP

Reputation: 97996

Composer's "global install" functionality works by setting up a Composer project in a particular directory and managing it in the normal way. As the manual states:

The global command allows you to run other commands like install, remove, require or update as if you were running them from the COMPOSER_HOME directory.

This is merely a helper to manage a project stored in a central location that can hold CLI tools or Composer plugins that you want to have available everywhere.

This is key to understanding the output you saw, which begins:

Changed current directory to /Users/emmanuelezejiugo/.composer

Everything after this happens as though you'd run a normal composer command in that directory.

The first part of the conflict is fairly straight-forward:

  • emmajiugo/flutterwave-cli v1.3 requires laravel-zero/framework ^7.0
  • laravel-zero/framework v7.x requires illuminate/container ^7.0

The reason that's causing a conflict shows up right at the end of the message:

  • Installation request for illuminate/container (locked at v5.8.28)

This is referring to you having "locked" that package to a particular version in the composer.json for the project where you're currently installing packages. In other words, you're trying to add two requirements for that project that contradict each other.

As we've established above, that project is not your new library, it is the project composer has created in /Users/emmanuelezejiugo/.composer. So the configuration you need to change is in /Users/emmanuelezejiugo/.composer/composer.json.

The simplest solution is probably not to install the library in that folder. As noted above, the composer global command isn't actually doing anything other than changing directory for you; most of the time, you're better off creating a directory for each project or tool and requiring its dependencies there, even if you only need a local copy to run some commands.

Upvotes: 2

Nico Haase
Nico Haase

Reputation: 12131

Have you tried to read the error message? One line tells you the problem:

emmajiugo/flutterwave-cli v1.3 requires laravel-zero/framework ^7.0

On the other hand, your composer.json requires "laravel-zero/framework": "^5.8" - these two requirements obviously do not work together. You should either require a lower version of Laravel in your library, or require a later version of Laravel in your application

Upvotes: 3

Related Questions