Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found #186

Closed
briantully opened this issue Jun 8, 2019 · 13 comments · Fixed by #207
Assignees
Labels

Comments

@briantully
Copy link

briantully commented Jun 8, 2019

Steps required to reproduce the problem

  1. install globally via composer global require localheinz/composer-normalize
  2. cd to composer project directory and run composer normalize --dry-run

Expected Result

  • a diff output of what changes would be applied

Actual Result

  • PHP Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found
PHP Fatal error:  Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found in /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php:73
Stack trace:
#0 /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/NormalizePlugin.php(52): Localheinz\Composer\Normalize\Command\NormalizeCommand->__construct(Object(Composer\Factory), Object(Localheinz\Composer\Json\Normalizer\ComposerJsonNormalizer))
#1 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(466): Localheinz\Composer\Normalize\NormalizePlugin->getCommands()
#2 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(156): Composer\Console\Application->getPluginCommands()
#3 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 p in /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php on line 73

Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found in /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php:73
Stack trace:
#0 /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/NormalizePlugin.php(52): Localheinz\Composer\Normalize\Command\NormalizeCommand->__construct(Object(Composer\Factory), Object(Localheinz\Composer\Json\Normalizer\ComposerJsonNormalizer))
#1 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(466): Localheinz\Composer\Normalize\NormalizePlugin->getCommands()
#2 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(156): Composer\Console\Application->getPluginCommands()
#3 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 p in /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php on line 73

I've tried clearing composer's cache and reinstalling composer-normalize to no avail. Running latest stable composer (1.8.5)

@briantully
Copy link
Author

FWIW I read #68 and tried downgrading composer to 1.7.1 and 1.6.5 but still had the same issue.

@localheinz localheinz self-assigned this Jun 8, 2019
@localheinz localheinz added the bug label Jun 8, 2019
@localheinz
Copy link
Member

Thank you for your report, @briantully!

I’m going to take a look at this tomorrow - I hope this will work for you.

@briantully
Copy link
Author

Of course @localheinz ! Thanks a bunch. Let me know what I can do to help :)

@localheinz
Copy link
Member

localheinz commented Jun 18, 2019

@briantully

Apologies for the late reply, I unfortunately did not manage to take a look before heading off for a couple days at the Baltic Sea.

sebastian/diff:^2.0.0

I have tried to reproduce the issue by running

$ rm -rf ~/.composer
$ composer global require sebastian/diff:^2.0.0 localheinz/composer-normalize

Then running

$ composer global show --direct

gives me

Changed current directory to /Users/am/.composer
localheinz/composer-normalize 1.2.0 Provides a composer plugin for normalizing composer.json.
sebastian/diff                2.0.1 Diff implementation

and when I run

$ composer normalize --dry-run

in a directory that contains the following composer.json

{
  "name": "localheinz/composer-normalize",
  "type": "composer-plugin",
  "description": "Provides a composer plugin for normalizing composer.json.",
  "require": {
    "composer-plugin-api": "^1.1.0",
    "php": "^7.1"
  }
}

this gives me

./composer.json is not normalized.

---------- begin diff ----------
--- original
+++ normalized
@@ @@
 {
   "name": "localheinz/composer-normalize",
   "type": "composer-plugin",
   "description": "Provides a composer plugin for normalizing composer.json.",
   "require": {
-    "composer-plugin-api": "^1.1.0",
-    "php": "^7.1"
+    "php": "^7.1",
+    "composer-plugin-api": "^1.1.0"

----------- end diff -----------

sebastian/diff:^3.0.0

I have also tried to reproduce the issue by running

$ rm -rf ~/.composer
$ composer global require sebastian/diff:^3.0.0 localheinz/composer-normalize

Then running

$ composer global show --direct

gives me

Changed current directory to /Users/am/.composer
localheinz/composer-normalize 1.2.0 Provides a composer plugin for normalizing composer.json.
sebastian/diff                3.0.2 Diff implementation

and when I run

$ composer normalize --dry-run

in a directory that contains the following composer.json

{
  "name": "localheinz/composer-normalize",
  "type": "composer-plugin",
  "description": "Provides a composer plugin for normalizing composer.json.",
  "require": {
    "composer-plugin-api": "^1.1.0",
    "php": "^7.1"
  }
}

this gives me

./composer.json is not normalized.

---------- begin diff ----------
--- original
+++ normalized
@@ -3,7 +3,7 @@
   "type": "composer-plugin",
   "description": "Provides a composer plugin for normalizing composer.json.",
   "require": {
-    "composer-plugin-api": "^1.1.0",
-    "php": "^7.1"
+    "php": "^7.1",
+    "composer-plugin-api": "^1.1.0"
   }
 }

----------- end diff -----------

Not sure, maybe I'm missing something?

@localheinz
Copy link
Member

@briantully

Ha, just ran into this - running

$ md ~/Sites/justinrainbow && cd ~/Sites/justinrainbow
$ git clone git@github.com:justinrainbow/json-schema.git
$ cd json-schema
$ composer install

yields

Deprecation warning: require-dev.json-schema/JSON-Schema-Test-Suite is invalid, it should not contain uppercase characters. Please use json-schema/json-schema-test-suite instead. Make sure you fix this as Composer 2.0 will error.
PHP Fatal error:  Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found in /Users/am/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php:73
Stack trace:
#0 /Users/am/.composer/vendor/localheinz/composer-normalize/src/NormalizePlugin.php(52): Localheinz\Composer\Normalize\Command\NormalizeCommand->__construct(Object(Composer\Factory), Object(Localheinz\Composer\Json\Normalizer\ComposerJsonNormalizer))
#1 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(466): Localheinz\Composer\Normalize\NormalizePlugin->getCommands()
#2 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(156): Composer\Console\Application->getPluginCommands()
#3 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/local/C in /Users/am/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php on line 73

Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found in /Users/am/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php:73
Stack trace:
#0 /Users/am/.composer/vendor/localheinz/composer-normalize/src/NormalizePlugin.php(52): Localheinz\Composer\Normalize\Command\NormalizeCommand->__construct(Object(Composer\Factory), Object(Localheinz\Composer\Json\Normalizer\ComposerJsonNormalizer))
#1 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(466): Localheinz\Composer\Normalize\NormalizePlugin->getCommands()
#2 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(156): Composer\Console\Application->getPluginCommands()
#3 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/local/C in /Users/am/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php on line 73

@localheinz
Copy link
Member

@briantully

Can you do me a favor and run

$ composer show | grep phpunit

in the directory in which you ran

$ composer normalize

resulting in the error you reported?

@briantully
Copy link
Author

Hi there @localheinz -- no worries. A couple of days on the Baltic Sea sounds lovely! Hope you had a great time :)

Interestingly enough, when I reinstalled composer-normalize today, I am not longer experiencing the issue. I'm not sure if it's because I don't remember the project I was trying to run it on, or if it's because I did some cleanup and removed some global composer packages last weekend (which may or may not have included phpunit).

In any event, I'm no longer seeing the PHP Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found error when running composer normalize --dry-run in several composer projects.

Thanks again!

@begrafx
Copy link

begrafx commented Jun 21, 2019

I got the same thing. I did a
composer global update

which executed without issue. Then, I did a
composer update and then attempted to do a composer normalize to clean things up, and I got

Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found in /Users/brianeller/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php:73
Stack trace:
#0 /Users/brianeller/.composer/vendor/localheinz/composer-normalize/src/NormalizePlugin.php(52): Localheinz\Composer\Normalize\Command\NormalizeCommand->__construct(Object(Composer\Factory), Object(Localheinz\Composer\Json\Normalizer\ComposerJsonNormalizer))
#1 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(466): Localheinz\Composer\Normalize\NormalizePlugin->getCommands()
#2 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(156): Composer\Console\Application->getPluginCommands()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(1 in /Users/brianeller/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php on line 73

I re-ran the global update, thinking perhaps something had been corrupted. just got the "nothing to update" message. I checked here, and find that the same message has already been reported, so I'll add my experience on this.

@begrafx
Copy link

begrafx commented Aug 8, 2019

This is still an issue. I simply attempted to do an update, and this was the result:

$ composer update

Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found in /Users/brianeller/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php:73
Stack trace:
#0 /Users/brianeller/.composer/vendor/localheinz/composer-normalize/src/NormalizePlugin.php(52): Localheinz\Composer\Normalize\Command\NormalizeCommand->__construct(Object(Composer\Factory), Object(Localheinz\Composer\Json\Normalizer\ComposerJsonNormalizer))
#1 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(466): Localheinz\Composer\Normalize\NormalizePlugin->getCommands()
#2 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(156): Composer\Console\Application->getPluginCommands()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(1 in /Users/brianeller/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php on line 73

Understandably, this is unacceptable. Yes, I have, again done a "composer global update", which completes without issue, but this error persists.

@glensc
Copy link

glensc commented Sep 2, 2019

This appears to be a problem when having phpunit 4.8 in project dependencies.

This can be fixed either by removing global ~/.composer/vendor or project ./vendor

I think this problem must be solved some other way, by having code moved to phar installation, and only provide composer plugin, so the dependencies are thin and isolated from project dependencies.

The other soliution is namespacing all dependencies using php scoper:

@glensc
Copy link

glensc commented Sep 2, 2019

If this project provided phar file, could invoke the command using composer-git-hooks

@localheinz
Copy link
Member

Sebastian Bergmann allowed me to fork sebastian/diff for use with this project, so I'm using localheinz/diff now instead.

#207 should fix this problem!

@localheinz
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants