liborm85 / composer-vendor-cleaner

Composer Vendor Cleaner removes unnecessary development files and directories from vendor directory.
MIT License
27 stars 3 forks source link

“[RuntimeException] Directory name must not be empty.“ while iterating directories #1

Closed marcoliverteschke closed 3 years ago

marcoliverteschke commented 3 years ago

Hi!

I'm testing out your plugin to clean up the vendor directory of a Drupal 8 installation, but when the plugin is enabled I encounter an exception.

I have required the plugin and configured it thus to try it out:

"dev-files": { "vendor/": [ "tests/", "docs/", ".travis.yml", "doc/" ] }

Now when I no-dev-install my dependencies, eventually I get:

[RuntimeException] Directory name must not be empty.

With the following exception trace:

Exception trace:
 () at /Users/marc/workspace/drupal8.marcmachttheater.de/vendor/liborm85/composer-vendor-cleaner/src/Directory.php:57
 RecursiveDirectoryIterator->__construct() at /Users/marc/workspace/drupal8.marcmachttheater.de/vendor/liborm85/composer-vendor-cleaner/src/Directory.php:57
 Liborm85\ComposerVendorCleaner\Directory->getDirectories() at /Users/marc/workspace/drupal8.marcmachttheater.de/vendor/liborm85/composer-vendor-cleaner/src/Cleaner.php:150
 Liborm85\ComposerVendorCleaner\Cleaner->removeEmptyDirectories() at /Users/marc/workspace/drupal8.marcmachttheater.de/vendor/liborm85/composer-vendor-cleaner/src/Cleaner.php:97
 Liborm85\ComposerVendorCleaner\Cleaner->cleanupPackages() at /Users/marc/workspace/drupal8.marcmachttheater.de/vendor/liborm85/composer-vendor-cleaner/src/Plugin.php:147
 Liborm85\ComposerVendorCleaner\Plugin->cleanup() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:164
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:96
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:112
 Composer\Autoload\AutoloadGenerator->dump() at phar:///usr/local/bin/composer/src/Composer/Installer.php:307
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/InstallCommand.php:122
 Composer\Command\InstallCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:281
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:113
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:61
 require() at /usr/local/bin/composer:24

Not sure, what the right approach would be here. Have the directory iterator skip empty paths would be the most obvious solution, but that's just working around the symptom, not really addressing the cause…?

liborm85 commented 3 years ago

Hi. Can you provide whole composer.json file with requires? So I can test it.

marcoliverteschke commented 3 years ago

Sure thing, here you go! (Had to add .txt to make Github allow me uploading it) composer.json.txt

liborm85 commented 3 years ago

Fixed by commit https://github.com/liborm85/composer-vendor-cleaner/commit/6a32bcb59a19a07108c6c786c39bcbb8f9afa7c4. Released in version 1.4.0.

Thanks.

marcoliverteschke commented 3 years ago

I can confirm, the bug is solved. Thanks!