Ocramius / PackageVersions

:package: Composer addon to efficiently get installed packages' version numbers
MIT License
3.22k stars 67 forks source link

After "global require", "composer install" got broken. #67

Closed hirak closed 6 years ago

hirak commented 6 years ago

description

  1. composer global require ocramius/package-versions
  2. At any repository without composer.lock, "composer install" will fail.

why "global require"

This pkg required by phpstan/phpstan. I tried to install it with composer global require.

reproduction procedure

$ composer global require 'ocramius/package-versions'

$ mkdir test && cd test

$ composer init
# ...
$ cat composer.json  # for example
{
    "name": "hiraku/test",
    "type": "library",
    "license": "proprietary",
    "authors": [{"name": "Hiraku NAKANO"}],
    "require": {}
}
$ composer install -vvv
# ...
Nothing to install or update
Reading /Users/hiraku/sandbox/php/foo/vendor/composer/installed.json
Generating autoload files

  [LogicException]                                   
  No lockfile found. Unable to read locked packages  

Exception trace:
 () at phar:///Users/hiraku/bin/composer.phar/src/Composer/Package/Locker.php:266
 Composer\Package\Locker->getLockData() at /Users/hiraku/.composer/vendor/ocramius/package-versions/src/PackageVersions/Installer.php:157
 PackageVersions\Installer::getVersions() at n/a:n/a
 iterator_to_array() at /Users/hiraku/.composer/vendor/ocramius/package-versions/src/PackageVersions/Installer.php:82
 PackageVersions\Installer::dumpVersionsClass() at n/a:n/a
 call_user_func() at phar:///Users/hiraku/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:176
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///Users/hiraku/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:96
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///Users/hiraku/bin/composer.phar/src/Composer/Installer.php:323
 Composer\Installer->run() at phar:///Users/hiraku/bin/composer.phar/src/Composer/Command/InstallCommand.php:119
 Composer\Command\InstallCommand->execute() at phar:///Users/hiraku/bin/composer.phar/vendor/symfony/console/Command/Command.php:242
 Symfony\Component\Console\Command\Command->run() at phar:///Users/hiraku/bin/composer.phar/vendor/symfony/console/Application.php:843
 Symfony\Component\Console\Application->doRunCommand() at phar:///Users/hiraku/bin/composer.phar/vendor/symfony/console/Application.php:193
 Symfony\Component\Console\Application->doRun() at phar:///Users/hiraku/bin/composer.phar/src/Composer/Console/Application.php:254
 Composer\Console\Application->doRun() at phar:///Users/hiraku/bin/composer.phar/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///Users/hiraku/bin/composer.phar/src/Composer/Console/Application.php:103
 Composer\Console\Application->run() at phar:///Users/hiraku/bin/composer.phar/bin/composer:56
 require() at /Users/hiraku/bin/composer.phar:25

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
Ocramius commented 6 years ago

This isn't fixable on my end, as this package really can't know whether it is running from a global require or a package-specific require (much like it can't operate under "vendor-dir" customisation).

My generic advice is to stop using composer global require overall: haven't needed it in over 5 years of extensive composer daily usage, and won't need it anytime soon anyway :-)

Closing as can't fix and also won't fix, sorry.