ajthinking
ajthinking

Reputation: 4538

composer global require fails where non global equivalent succeeds

Im developing a package available at packagist as user/package. Installing it locally works just fine

composer require user/package

Creating a new project is also fine

composer create-project --prefer-dist user/package new-project

But the package is to be deployed globally

composer global require user/package

however this results in the following error log.

Changed current directory to /home/anders/.composer ./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 user/package ^v0.0.3 -> satisfiable by user/package[v0.0.3]. - Conclusion: remove illuminate/container v5.5.2 - Conclusion: don't install illuminate/container v5.5.2 - don't install tightenco/collect v5.4.33|don't install laravel/framework v5.5.2 - don't install laravel/framework v5.5.2|remove tightenco/collect v5.4.33 - Installation request for illuminate/container (installed at v5.5.2) -> satisfiable by illuminate/container[v5.5.2], laravel/framework[v5.5.2]. - Installation request for tightenco/collect (installed at v5.4.33) -> satisfiable by tightenco/collect[v5.4.33].

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

How can this be?

Here is my composer.json

{
    "name": "user/package",
    "description": "Package",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "ajthinking/tinx": "^2.1",
        "fideloper/proxy": "~3.3",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "~1.0",
        "phpunit/phpunit": "~6.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "bin": [
        "package"
    ]    
}

Would really appreciate help interpreting the error log. Thanks!

Update

This is the content of /home/anders/.composer/

{
    "require": {
        "cpriego/valet-linux": "^2.0",
        "laravel/installer": "^1.4",
        "phpunit/phpunit": "^6.4",
        "phpunit/dbunit": "^3.0"
    }
}

Composer version: 1.6.5

Upvotes: 2

Views: 686

Answers (1)

rob006
rob006

Reputation: 22164

If this is standalone tool, you should consider building PHAR for it. You can use kherge/box to simplify build process.

PHAR archive is completely standalone, so you'll get rid of all problems with conflicting global dependencies. It may also simplify installation (you need to just download archive and make it executable) for both global and local installation.

Upvotes: 2

Related Questions