Skip to content

Coding Standard tries itself to install with installPath when it's the root package #19

@bastianschwarz

Description

@bastianschwarz

Problem/Motivation

Today, I started to develop my own coding style. Of course, I want to use the same CI tools, including PHPCompatibility. Unfortunately, the installer tries to install the root package by using the install path (which isn't available, since the root package of course doesn't install itself).

Expected behaviour

The installer should install all dependency packages with the install path, but either ignore the root package or install the root package using the repo root.

Actual behaviour

The installer tries to install the root package with its install path:

bastian@bastian-codenamephp:~/workspace/codenamephp/codingstandard$ composer update -v
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files

                                                                                                                        
  [InvalidArgumentException]                                                                                            
  The "/home/bastian/workspace/codenamephp/codingstandard/vendor/codenamephp/codingstandard" directory does not exist.  

Exception trace:
 () at phar:///usr/bin/composer/vendor/symfony/finder/Finder.php:656
 Symfony\Component\Finder\Finder->in() at /home/bastian/workspace/codenamephp/codingstandard/vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php:255
 Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer\Plugin->updateInstalledPaths() at /home/bastian/workspace/codenamephp/codingstandard/vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php:147
 Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer\Plugin->onDependenciesChangedEvent() at n/a:n/a
 call_user_func() at phar:///usr/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:171
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:96
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///usr/bin/composer/src/Composer/Installer.php:307
 Composer\Installer->run() at phar:///usr/bin/composer/src/Composer/Command/UpdateCommand.php:158
 Composer\Command\UpdateCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php:257
 Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:850
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:193
 Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:227
 Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:124
 Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:100
 Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:54
 require() at /usr/bin/composer:24

Steps to reproduce

Create a package with type "type": "phpcodesniffer-standard" and the installer as dependency:

{
  "name": "vendor/package",
  "type": "phpcodesniffer-standard",
  "require": {
    "php": "^7.0",
    "squizlabs/php_codesniffer": "3.0.x-dev as 2.0.0"
  },
  "require-dev": {
    "dealerdirect/phpcodesniffer-composer-installer": "*",
    "frenck/php-compatibility": "*"
  },
  "autoload": {
    "classmap": ["src/main/php"]
  },
  "autoload-dev": {
    "psr-0": {
      "CodenamePHP": ["src/main/php", "src/test/php"]
    }
  }
}

The problem repo will be https://github.com/codenamephp/codingstandard but the code is not comitted yet (obviously)

Proposed changes

The root could either be ignored or installed via the root path.

Ignoring the package would be easy by adding a check for instanceof RootPackageInterface in updateInstalledPaths().

Choosing the correct path could be done by the same instance of check when getting the install path in updateInstalledPaths().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions