8000 [DependencyInjection] The file "../src/" does not exist (in: "config/packages"). · Issue #40990 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[DependencyInjection] The file "../src/" does not exist (in: "config/packages"). #40990
Closed
@MatTheCat

Description

@MatTheCat

Symfony version(s) affected: ≥ 5.1 I guess

Description
I tried to create an app using only PHP config files (using ConfigBuilder) which made me simplify Kernel::configureContainer to

$container->import('../config/packages/*.php');

$path = \dirname(__DIR__).'/config/services.php';
(require $path)($container->withPath($path), $this);

This last line then triggers a FileLocatorFileNotFoundException saying

The file "../src/" does not exist (in: "/project/dir/config/packages").

Stacktrace
at vendor/symfony/config/FileLocator.php:71
 Symfony\Component\Config\FileLocator->locate() at vendor/symfony/http-kernel/Config/FileLocator.php:44
 Symfony\Component\HttpKernel\Config\FileLocator->locate() at vendor/symfony/config/Loader/FileLoader.php:118
 Symfony\Component\Config\Loader\FileLoader->glob() at vendor/symfony/dependency-injection/Loader/FileLoader.php:192
 Symfony\Component\DependencyInjection\Loader\FileLoader->findClasses() at vendor/symfony/dependency-injection/Loader/FileLoader.php:103
 Symfony\Component\DependencyInjection\Loader\FileLoader->registerClasses() at vendor/symfony/dependency-injection/Loader/Configurator/PrototypeConfigurator.php:69
 Symfony\Component\DependencyInjection\Loader\Configurator\PrototypeConfigurator->__destruct() at config/services.php:12
 App\Kernel::{closure}() at src/Kernel.php:19
 App\Kernel->configureContainer() at vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:155
 App\Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}() at vendor/symfony/dependency-injection/Loader/ClosureLoader.php:39
 Symfony\Component\DependencyInjection\Loader\ClosureLoader->load() at vendor/symfony/config/Loader/DelegatingLoader.php:40
 Symfony\Component\Config\Loader\DelegatingLoader->load() at vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:163
 App\Kernel->registerContainerConfiguration() at vendor/symfony/http-kernel/Kernel.php:645
 Symfony\Component\HttpKernel\Kernel->buildContainer() at vendor/symfony/http-kernel/Kernel.php:541
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at vendor/symfony/http-kernel/Kernel.php:783
 Symfony\Component\HttpKernel\Kernel->preBoot() at vendor/symfony/http-kernel/Kernel.php:122
 Symfony\Component\HttpKernel\Kernel->boot() at vendor/symfony/http-kernel/Kernel.php:140
 Symfony\Component\HttpKernel\Kernel->reboot() at vendor/symfony/framework-bundle/Command/CacheClearCommand.php:237
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at vendor/symfony/framework-bundle/Command/CacheClearCommand.php:156
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at vendor/symfony/console/Command/Command.php:288
 Symfony\Component\Console\Command\Command->run() at vendor/symfony/console/Command/LazyCommand.php:69
 Symfony\Component\Console\Command\LazyCommand->run() at vendor/symfony/console/Application.php:992
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at vendor/symfony/console/Application.php:291
 Symfony\Component\Console\Application->doRun() at vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at vendor/symfony/console/Application.php:167
 Symfony\Component\Console\Application->run() at vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:56
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at vendor/autoload_runtime.php:27
 require_once() at bin/console:11

How to reproduce
Run composer install or bin/console c:c on https://github.com/MatTheCat/reproducer

Possible Solution
I suspect the issue comes from the loader’s current directory not being reset when ContainerConfigurator::withPath is called.

final public function withPath(string $path): self
{
    $clone = clone $this;
    $clone->path = $clone->file = $path;
+   $clone->loader->setCurrentDir(\dirname($path));

     return $clone;
}

seems to fix the issue but I don’t know if it is any good.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0