3
votes

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?

  • I have tried composer global clearcache
  • Deleted a composer.lock file I found directly under /home/anders/.composer/
  • Upgraded my dependencies (Laravel) from 5.5.x to 5.6.x with no effect
  • Even creating a fresh "laravel new blog" project and uploading to packagist fails with the same error message.

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

1
What are the contents of you /home/anders/.composer/composer.json file?jrdn
@jrdn Please see updated answerajthinking
It looks like cpriego/valet-linux may have installed a lower version of the laravel container (5.1 - 5.3) than your package requires (5.5.*) (Just from checking the composer.json file from cpriego/valet-linux)jrdn
Oboy, im really screwed. Need private dependencies badly. Might try to wrap whole package in an extra folder to keep an "internal" vendors dir triggered by some event. But unfotunately there is no post-require script what I can see. Any other solutions? Package consolidation/cgr looks good but dont want to force that upon users.ajthinking
Have you considered using Docker to package everything together away from the rest of the system?jrdn

1 Answers

1
votes

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.