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

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

Closed
grizmio opened this issue Jul 22, 2020 · 7 comments · Fixed by #804

Comments

@grizmio
Copy link

grizmio commented Jul 22, 2020

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:
- '../src/Entity/'
- '../src/Kernel.php'

[https://github.com/symfony/recipes/commit/60d0656cf54e23957a4a99800a8e7f703bde49ed#diff-6b7648a9438bee9cf5db0ea78acbc00f](https://github.com/symfony/recipes/commit/60d0656cf54e23957a4a99800a8e7f703bde49ed#diff-6b7648a9438bee9cf5db0ea78acbc00f)


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
Copy link
Member

fabpot commented Jul 24, 2020

/cc @lyrixx

@lyrixx
Copy link
Member

lyrixx commented Jul 24, 2020

I already replied there : 60d0656

@lyrixx
Copy link
Member

lyrixx commented Jul 27, 2020

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
Copy link
Member

stof commented Jul 27, 2020

@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
Copy link
Member

lyrixx commented Jul 27, 2020

@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 symfony/symfony@a67abe1#diff-ad1ed76aba6a80df5a48dfa4585adcf3L164 :

Merge branch '3.4' into 4.4

But the real changes comes from symfony/symfony@2f65a7a and so symfony/symfony#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 :

  • 1️⃣ Revert this patch - but to me, this would reduce the DX ;
  • 2️⃣ Adpat this patch : instead of adding a list of path, we could comment "problematic" path like DependencyInjection, and Entity ;
  • 3️⃣ Nothing : People will find this issue and we will learn they should remove the "faulty line". We should not forget this is a very edge case where people are running 4.2 or 4.3 and override the current services.yaml. IMHO, it should not happen that much ;
  • 4️⃣Replace the full services.yaml in symfony 4.4 recipes (now it's a symlink to 4.2). So 4.2, 4.3 will have the previous file, and 4.4+ will have the "new" file with a better DX

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

WDYT?

@xabbuh
Copy link
Member

xabbuh commented Jul 27, 2020

4️⃣ looks good to me

@Gildedter
Copy link

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

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

Successfully merging a pull request may close this issue.

6 participants