beberlei / composer-monorepo-plugin

Integrates Composer into monolithic repositories with many packages.
MIT License
305 stars 41 forks source link

Duplicates composer behavior when conflicting binary files are found. #45

Closed robotoer closed 6 years ago

robotoer commented 6 years ago

Currently when two dependencies of a monorepo package have a binary with the same name, the composer-monorepo-plugin will crash with:

18:30 $ composer install --verbose
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Dependency resolution completed in 0.006 seconds
Analyzed 449 packages to resolve dependencies
Analyzed 1935 rules to resolve dependencies
Nothing to install or update
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Package herrera-io/json is abandoned, you should avoid using it. Use kherge/json instead.
Package herrera-io/phar-update is abandoned, you should avoid using it. No replacement was suggested.
Package kherge/version is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
Generating autoload files for monorepo sub-packages with dev-dependencies.
 [Subpackage] usere/webservices/api

  [ErrorException]        
  symlink(): File exists  

Exception trace:
 () at /Users/robert/fda/fda-development/FDA/vendor/beberlei/composer-monorepo-plugin/src/main/Monorepo/Build.php:100
 Composer\Util\ErrorHandler::handle() at n/a:n/a
 symlink() at /Users/robert/fda/fda-development/FDA/vendor/beberlei/composer-monorepo-plugin/src/main/Monorepo/Build.php:100
 Monorepo\Build->build() at /Users/robert/fda/fda-development/FDA/vendor/beberlei/composer-monorepo-plugin/src/main/Monorepo/Composer/Plugin.php:46
 Monorepo\Composer\Plugin->generateMonorepoAutoloads() at n/a:n/a
 call_user_func() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:171
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:96
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/Autoload/AutoloadGenerator.php:312
 Composer\Autoload\AutoloadGenerator->dump() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/Installer.php:302
 Composer\Installer->run() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/Command/InstallCommand.php:119
 Composer\Command\InstallCommand->execute() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/vendor/symfony/console/Command/Command.php:242
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/vendor/symfony/console/Application.php:842
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/vendor/symfony/console/Application.php:193
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/Console/Application.php:251
 Composer\Console\Application->doRun() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/Console/Application.php:100
 Composer\Console\Application->run() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/bin/composer:58
 require() at /usr/local/Cellar/composer/1.6.3/libexec/composer.phar:24

This PR duplicates the behavior that composer itself has to handle this type of conflict: To just print a warning and skip the binary file if a conflicting one already has been symlinked.

robotoer commented 6 years ago

You can try this out by adding:

    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:robotoer/composer-monorepo-plugin.git"
        }
    ],
    "require": {
        "beberlei/composer-monorepo-plugin": "dev-binaries-fix"
    }

to your composer.json

beberlei commented 6 years ago

Good catch, thank you for the contribution.