symfony / recipes

Symfony Recipes Repository
https://github.com/symfony/recipes/blob/flex/main/RECIPES.md
MIT License
973 stars 478 forks source link

post-install-cmd calls cache:clear and throws ../src/DependencyInjection" does not exist when running composer install #803

Closed grizmio closed 4 years ago

grizmio commented 4 years ago

I'm installing symfony with "composer install" from composer.json and composer.lock, but with an array if a directory is missing it thows an error at cache:clear in post install

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In FileLoader.php line 166:
!!                                                                                 
!!    The file "../src/DependencyInjection" does not exist (in:   
!!    /symfony_prueba/config) in /symfony_prueba/config/services.yaml 
!!    (which is loaded in resource "/symfony_prueba/config/services.yaml").               
!!                                                                                 
!!  
!!  In FileLocator.php line 71:
!!                                                                                 
!!    The file "../src/DependencyInjection" does not exist (in: /symfony_prueba/config).                                      
!!                                                                                 
!!  
!!  

Script @auto-scripts was called via post-install-cmd If a rollback this change it works like before, if i change the sequence to: App\: resource: '../src/' exclude:

The commit is: https://github.com/symfony/recipes/commit/60d0656cf54e23957a4a99800a8e7f703bde49ed#diff-6b7648a9438bee9cf5db0ea78acbc00f If you need my composer.json and composer.lock, please let me know and i will upload them.

fabpot commented 4 years ago

/cc @lyrixx

lyrixx commented 4 years ago

I already replied there : https://github.com/symfony/recipes/commit/60d0656cf54e23957a4a99800a8e7f703bde49ed

lyrixx commented 4 years ago

Thanks for taking time to answer me and I see it working. I think you are right about versions, at work we are using symfony 4.3, plus probably I'm doing something wrong. Inside a Dockerfile, we use composer.json and composer.lock in a new clean directory and run composer install to see a nice error. I know, we should start using 4.4 at least, but that would be a little "complicated". To try our use case you could do: mkdir foo ; cd foo ; copy composer_files_here; composer install The files: https://transfer.sh/%28/7bIIb/composer.json,/4t9uS/composer.lock%29.tar.gz

If you know a better way or "the right way" of doing it, I will really appreciate it. Thanks again.

@grizmio I'm not able to reproduce, because when I install vendor from, as the projet is empty, it can not work:

>/tmp/postinstall composer install --ignore-platform-reqs
The "ocramius/package-versions" plugin was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.
The "symfony/flex" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package guzzlehttp/ringphp is abandoned, you should avoid using it. No replacement was suggested.
Package guzzlehttp/streams is abandoned, you should avoid using it. No replacement was suggested.
Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.
Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.
Generating autoload files
> symfony-cmd
sh: 1: symfony-cmd: not found
Script symfony-cmd handling the auto-scripts event returned with error code 127
Script @auto-scripts was called via post-install-cmd

Can you create a reproducer instead? Thanks

stof commented 4 years ago

@lyrixx the error you got in your case is because symfony/flex was skipped due to conflicting with Composer 2. you might need to try it with Composer 1

lyrixx commented 4 years ago

@stof Thanks. I managed to reproduce the issue:

The full trace ``` >/tmp/postinstall(master *%) bin/console -v In FileLoader.php line 166: [Symfony\Component\Config\Exception\LoaderLoadException] The file "../src/DependencyInjection/" does not exist (in: /tmp/postinstall/config) in /tmp/postinstall/config/services.yaml (which is loaded in resource "/tmp/posti nstall/config/services.yaml"). Exception trace: () at /tmp/postinstall/vendor/symfony/config/Loader/FileLoader.php:166 Symfony\Component\Config\Loader\FileLoader->doImport() at /tmp/postinstall/vendor/symfony/config/Loader/FileLoader.php:90 Symfony\Component\Config\Loader\FileLoader->import() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/GlobFileLoader.php:27 Symfony\Component\DependencyInjection\Loader\GlobFileLoader->load() at /tmp/postinstall/vendor/symfony/config/Loader/DelegatingLoader.php:40 Symfony\Component\Config\Loader\DelegatingLoader->load() at /tmp/postinstall/src/Kernel.php:42 App\Kernel->configureContainer() at /tmp/postinstall/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:80 App\Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/ClosureLoader.php:38 Symfony\Component\DependencyInjection\Loader\ClosureLoader->load() at /tmp/postinstall/vendor/symfony/config/Loader/DelegatingLoader.php:40 Symfony\Component\Config\Loader\DelegatingLoader->load() at /tmp/postinstall/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:83 App\Kernel->registerContainerConfiguration() at /tmp/postinstall/vendor/symfony/http-kernel/Kernel.php:658 Symfony\Component\HttpKernel\Kernel->buildContainer() at /tmp/postinstall/vendor/symfony/http-kernel/Kernel.php:549 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /tmp/postinstall/vendor/symfony/http-kernel/Kernel.php:133 Symfony\Component\HttpKernel\Kernel->boot() at /tmp/postinstall/vendor/symfony/framework-bundle/Console/Application.php:159 Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /tmp/postinstall/vendor/symfony/framework-bundle/Console/Application.php:65 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /tmp/postinstall/vendor/symfony/console/Application.php:149 Symfony\Component\Console\Application->run() at /tmp/postinstall/bin/console:42 In FileLocator.php line 71: [Symfony\Component\Config\Exception\FileLocatorFileNotFoundException] The file "../src/DependencyInjection/" does not exist (in: /tmp/postinstall/config). Exception trace: () at /tmp/postinstall/vendor/symfony/config/FileLocator.php:71 Symfony\Component\Config\FileLocator->locate() at /tmp/postinstall/vendor/symfony/http-kernel/Config/FileLocator.php:52 Symfony\Component\HttpKernel\Config\FileLocator->locate() at /tmp/postinstall/vendor/symfony/config/Loader/FileLoader.php:110 Symfony\Component\Config\Loader\FileLoader->glob() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/FileLoader.php:114 Symfony\Component\DependencyInjection\Loader\FileLoader->findClasses() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/FileLoader.php:57 Symfony\Component\DependencyInjection\Loader\FileLoader->registerClasses() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php:568 Symfony\Component\DependencyInjection\Loader\YamlFileLoader->parseDefinition() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php:229 Symfony\Component\DependencyInjection\Loader\YamlFileLoader->parseDefinitions() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php:150 Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load() at /tmp/postinstall/vendor/symfony/config/Loader/FileLoader.php:151 Symfony\Component\Config\Loader\FileLoader->doImport() at /tmp/postinstall/vendor/symfony/config/Loader/FileLoader.php:90 Symfony\Component\Config\Loader\FileLoader->import() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/GlobFileLoader.php:27 Symfony\Component\DependencyInjection\Loader\GlobFileLoader->load() at /tmp/postinstall/vendor/symfony/config/Loader/DelegatingLoader.php:40 Symfony\Component\Config\Loader\DelegatingLoader->load() at /tmp/postinstall/src/Kernel.php:42 App\Kernel->configureContainer() at /tmp/postinstall/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:80 App\Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}() at /tmp/postinstall/vendor/symfony/dependency-injection/Loader/ClosureLoader.php:38 Symfony\Component\DependencyInjection\Loader\ClosureLoader->load() at /tmp/postinstall/vendor/symfony/config/Loader/DelegatingLoader.php:40 Symfony\Component\Config\Loader\DelegatingLoader->load() at /tmp/postinstall/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:83 App\Kernel->registerContainerConfiguration() at /tmp/postinstall/vendor/symfony/http-kernel/Kernel.php:658 Symfony\Component\HttpKernel\Kernel->buildContainer() at /tmp/postinstall/vendor/symfony/http-kernel/Kernel.php:549 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /tmp/postinstall/vendor/symfony/http-kernel/Kernel.php:133 Symfony\Component\HttpKernel\Kernel->boot() at /tmp/postinstall/vendor/symfony/framework-bundle/Console/Application.php:159 Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /tmp/postinstall/vendor/symfony/framework-bundle/Console/Application.php:65 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /tmp/postinstall/vendor/symfony/console/Application.php:149 Symfony\Component\Console\Application->run() at /tmp/postinstall/bin/console:42 ```

I found the culprit:

Signature of FileLoader::glob()

The change from "false" => "true" (ie ignore error) comes from this commit https://github.com/symfony/symfony/commit/a67abe1fb62bf5643e26192972af8417525d3896#diff-ad1ed76aba6a80df5a48dfa4585adcf3L164 :

Merge branch '3.4' into 4.4

But the real changes comes from https://github.com/symfony/symfony/commit/2f65a7a2556b09cbee7e7afb64b4bb432eaa5a7e and so https://github.com/symfony/symfony/pull/35772


So the current behavior is to ignore error (3.4, 4.4, 5.x) but since 4.3 is EOL, the commit did not reach this branch. Too bad to me :). More over, 4.2 is also affected

I don't know what can I do. Some options :

So, My preferred solutions, sorted by preference : 4️⃣, 3️⃣, 2️⃣, 1️⃣

WDYT?

xabbuh commented 4 years ago

4️⃣ looks good to me

Gildedter commented 2 years ago

having the same issue, I was running symfony new --version=6.0-1 --book guestbook --debug (currently reading the book since I'm new), within a laragon instance (Cmder terminal, PHP 8.1.9 NTS)

I get this error:

Generating optimized autoload files
84 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Run composer recipes at any time to see the status of your Symfony recipes.

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!
Script @auto-scripts was called via post-install-cmd
unable to run ~/AppData/Local/ComposerSetup/bin/composer.phar install