Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Analyze crashes on trying to create app’s presenter #3

Open
jtojnar opened this issue May 31, 2022 · 11 comments
Open

Analyze crashes on trying to create app’s presenter #3

jtojnar opened this issue May 31, 2022 · 11 comments

Comments

@jtojnar
Copy link

jtojnar commented May 31, 2022

Running vendor/bin/barista analyze in my Nette project using 08fa2df crashes with the following error:

Fatal error: Uncaught Nette\DI\ServiceCreationException: Service 'application.1' (type of App\Presenters\DashboardPresenter): Service of type App\Model\HelperLoader required by $helperLoader in App\Presenters\BasePresenter::__construct() not found. Did you add it to configuration file? in /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/Resolver.php:650
Stack trace:
#0 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/Resolver.php(577): Nette\DI\Resolver::autowireArgument(Object(ReflectionParameter), Object(Closure))
#1 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/Resolver.php(232): Nette\DI\Resolver::autowireArguments(Object(ReflectionMethod), Array, Object(Closure))
#2 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/Definitions/ServiceDefinition.php(226): Nette\DI\Resolver->completeStatement(Object(Nette\DI\Definitions\Statement))
#3 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/Resolver.php(168): Nette\DI\Definitions\ServiceDefinition->complete(Object(Nette\DI\Resolver))
#4 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/ContainerBuilder.php(332): Nette\DI\Resolver->completeDefinition(Object(Nette\DI\Definitions\ServiceDefinition))
#5 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/Compiler.php(275): Nette\DI\ContainerBuilder->complete()
#6 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/Compiler.php(212): Nette\DI\Compiler->processBeforeCompile()
#7 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/ContainerLoader.php(119): Nette\DI\Compiler->compile()
#8 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/ContainerLoader.php(81): Nette\DI\ContainerLoader->generate('Container_55cc0...', Array)
#9 /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/ContainerLoader.php(44): Nette\DI\ContainerLoader->loadFile('Container_55cc0...', Array)
#10 /home/jtojnar/Projects/eudyptes/vendor/nette/bootstrap/src/Bootstrap/Configurator.php(274): Nette\DI\ContainerLoader->load(Array, Array)
#11 /home/jtojnar/Projects/eudyptes/vendor/nette/bootstrap/src/Bootstrap/Configurator.php(252): Nette\Bootstrap\Configurator->loadContainer()
#12 /home/jtojnar/Projects/eudyptes/vendor/barista/barista/src/DI/BaristaContainerFactory.php(32): Nette\Bootstrap\Configurator->createContainer()
#13 /home/jtojnar/Projects/eudyptes/vendor/barista/barista/bin/barista.php(31): Barista\DI\BaristaContainerFactory->create(Array)
#14 /home/jtojnar/Projects/eudyptes/vendor/barista/barista/bin/barista(4): require('/home/jtojnar/P...')
#15 /home/jtojnar/Projects/eudyptes/vendor/bin/barista(117): include('/home/jtojnar/P...')
#16 {main}
  thrown in /home/jtojnar/Projects/eudyptes/vendor/nette/di/src/DI/Resolver.php on line 650

Initially reported in #2.

@TomasVotruba
Copy link
Member

I think the search config is hooking to your project and tries to load your appDir parameter.

How does it change, when you register services manually in barista config?

@jtojnar
Copy link
Author

jtojnar commented May 31, 2022

It is the same error when I drop the search extension in favour of manually registered services. I will try to reproduce this with nette-sandbox.

jtojnar added a commit to jtojnar/repro that referenced this issue May 31, 2022
@jtojnar
Copy link
Author

jtojnar commented May 31, 2022

I actually got a different error. I saw that one before as well.

@jtojnar
Copy link
Author

jtojnar commented May 31, 2022

Something fishy is in place. I deleted the presenters and run composer dump-autoload and now it cannot find the command. Maybe something with how symfony/console finds commands.

$ vendor/bin/barista analyze
                                     
  Command "analyze" is not defined.

@jtojnar
Copy link
Author

jtojnar commented May 31, 2022

$ vendor/bin/barista list
[...]
Available commands:
  completion  Dump the shell completion script
  help        Display help for a command
  lint        Lint your Latte files with your own Latte\Engine. Provide it via "barista.neon" > "parameters" > "latteProviderFile" parameter
  list        List commands

/me pulling hair

@TomasVotruba
Copy link
Member

TomasVotruba commented May 31, 2022

I'd be really interested in reproducer for this original one :)

Uncaught Nette\DI\ServiceCreationException: Service 'application.1' (t

@jtojnar
Copy link
Author

jtojnar commented May 31, 2022

Right. Since trying it in nette sandbox just gave me a different error message, I am trying to simplify my project by deleting files left and right. Only to get more and more bizarre errors.

I should probably step away from PHP for today.

@TomasVotruba
Copy link
Member

Yea, take your time and relax. Debugging can suck out of live very quickly, keep healthy 🍺 ☺️

@TomasVotruba
Copy link
Member

I tried to add more own dependency services, but it did not help to crash :/

The search extension works really poorly. I wish it allowed PHP syntax so we can use normal absolute path.

This is my random guess:
a0455c3

@jtojnar
Copy link
Author

jtojnar commented May 31, 2022

As mentioned, it does happen when I remove the search block so unless Nette adds it implicitly somehow, that should not be it. I ate something so hopefully I will be more productive now.

Edit: Right, still the same at a0455c3.

jtojnar added a commit to jtojnar/repro that referenced this issue May 31, 2022
The distinguishing factor is actually classmap autoload in composer.json.
@jtojnar
Copy link
Author

jtojnar commented May 31, 2022

After trying almost every possible subset of files to delete from the project, it turned out that classmap autoload is the determining factor, see https://github.com/jtojnar/repro/tree/f0d5ae9cc3a8e68b3d7098b172a5db80dcea0f2d/barista-3.

I have decided to port the legacy app to PSR-4 (unfortunately, Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector is insufficient).

Not sure if this is worth debugging further.

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

No branches or pull requests

2 participants