Closed matheo closed 10 years ago
Using it now in another symfony app it doesn't use the de_
environment but it present problems in prod
with a 500 Internal Server Error. In the app/logs/prod.log
appears this:
request.CRITICAL: Uncaught PHP Exception Twig_Error_Syntax:
"An exception has been thrown during the compilation of a template
("Dependency cache keys not yet generated, run "app/console sp:bower:install"
to initiate the cache: Cached dependencies for "app/cache/prod/sp_bower" not found,
create it with the method createDependencyMappingCache().")
in "FooBundle::layout.html.twig"." at /vendor/twig/twig/lib/Twig/Environment.php line 564 ... []
I'm processing only my FooBundle and no sp_bower.bundles.FooBundle.cache
works, not even the default dir :/ any clue why it's looking only on app/cache/prod/sp_bower
and just saving a bower.json
there?
I think it has something to do with the fact, that you use the kernel cache directory instead of the preconfigured bundle cache directory. Is the configuration for this app the same as you posted above?
Woot, I wasn't aware of your answer.
My apps are not working on prod
, not even with the default configuration :(
I'm trying to have a unique writable folder and subfolders per Bundle, it should not be a big deal moving the configuration, but no, even trying with the default configuration the app/logs/prod.log
states:
request.CRITICAL: "An exception has been thrown during the compilation of a template in
"::base.html.twig". " at /.../app/cache/prod/classes.php line 3120,
Sp\\BowerBundle\\Bower\\Exception\\RuntimeException:
Dependency cache keys not yet generated, run "app/console sp:bower:install" to initiate
the cache: Cached dependencies for "/.../app/cache/prod/sp_bower" not found, create it
with the method createDependencyMappingCache().
at /.../vendor/sp/bower-bundle/Sp/BowerBundle/Assetic/BowerResource.php:102"
And to avoid the error clearing the cache I need to use:
app/console cache:clear --no-warmup
or it throws:
[Sp\BowerBundle\Bower\Exception\RuntimeException]
Dependency cache keys not yet generated, run "app/console sp:bower:install" to initiate
the cache: Cached dependencies for "/.../app/cache/de_/sp_bower" not found,
create it with the method createDependencyMappingCache().
The ClearCache command uses that tricky environment, and I don't think it matters but anyways, the problem is: Why it throws Exception for app/cache/prod/sp_bower
when there's just a bower.json
?? There's a .bowerrc
on app/cache/dev/sp_bower
, but all the cache seems to be in the Resources/public/components/cache
folder of MyBundle, so what's BowerResource checking? :/
My configuration is this:
sp_bower:
bin: /usr/local/bin/bower
# cache_dir: %kernel.cache_dir%/../sp_bower
assetic:
enabled: true
nest_dependencies: true
# filters:
# css:
# - ?yui_css
# js:
# - ?uglifyjs
# packages:
# bootstrap:
# css:
# - cssrewrite
# js:
# - ?yui_js
bundles:
MyBundle:
asset_dir: %kernel.root_dir%/../web/vendor/
# cache:
# %kernel.cache_dir%/sp_bower/MyBundle
Thanks!
Somehow it creates different cacheKey's on the sp:bower:install
and the cache:clear
command.
On install, it does create the cached files, but the Doctrine\Common\Cache\FilesystemCache::doContains()
fails to recognise them when they have to be cleared.
The exception says to create the cache dependencies with the createDependencyMappingCache() method. I've tried to create the dependencies right before the $dependencyCache->contains() check like;
$this->createDependencyMappingCache($config);
if (!$dependencyCache->contains($cacheKey)) {
throw new RuntimeException(sprintf(
'Cached dependencies for "%s" not found, create it with the method createDependencyMappingCache().', $config->getDirectory()
));
}
This creates a new cache mapping and deletes it again, so that would mean the error is thrown cause of a difference in the configuration passed to the FilesystemCache.
Dumping the directory, passed to hash() method in createCacheKey(), results in different directories. On install it dumps /path/to/app/cache/dev/sp_bower
, while on cache:clear it dumps /path/to/app/cache/de_/sp_bower
. Forcing the exact same path still throws the Exception though...
Thanks for debuggin this. I will try to reproduce this behaviour and fix it.
FYI; Setting install_on_warmup to true fixes the exception
# app/config/config.yml
sp_bower:
install_on_warmup: true
Thank you, this helps :)
I'll just keep adding my findings;
I noticed all my controller tests kept failing cause of some Circular Reference error Circular reference detected in "." ("." > ".")
.
Debugging further i found the following error in my test.log;
[2014-03-28 11:56:09] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Config\Exception\FileLoaderLoadException:
"Cannot import resource "." from "/path/to/app/cache/test/assetic/routing.yml".
(Dependency cache keys not yet generated, run "app/console sp:bower:install" to
initiate the cache: Cached dependencies for "/path/to/app/cache/test/sp_bower"
not found, create it with the method createDependencyMappingCache().)" at /path/to/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php
line 104 {"exception":"[object](Symfony\\Component\\Config\\Exception\\FileLoaderLoadException:
Cannot import resource \".\" from \"/path/to/app/cache/test/assetic/routing.yml\".
(Dependency cache keys not yet generated, run \"app/console sp:bower:install\"
to initiate the cache: Cached dependencies for \"/path/to/app/cache/test/sp_bower\"
not found, create it with the method createDependencyMappingCache().) at
/path/to/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php:104,
Sp\\BowerBundle\\Bower\\Exception\\RuntimeException: Dependency cache keys not yet
generated, run \"app/console sp:bower:install\" to initiate the cache: Cached dependencies for
\"/path/to/app/cache/test/sp_bower\" not found, create it with the method
createDependencyMappingCache(). at /path/to/vendor/sp/bower-bundle/Sp/BowerBundle/Assetic/BowerResource.php:102)"} []
Setting assetic.enabled to false in my sp_bower config made the tests pass and also fixed the initial RuntimeException
The problem here was, that I created a different cache key during warmup. I just pushed a change to master, would be nice if you could try it and let me know, if your issue is fixed.
Still the same here...
To reproduce;
• Do a fresh Symfony 2.4 standard edition install.
• Add "sp/bower-bundle": "dev-master"
to composer.json.
• Add the following to app/config/config.yml:
sp_bower:
bundles:
AcmeDemoBundle: ~
• Composer update • Add the following to src/Acme/DemoBundle/Resources/config/bower/bower.json:
{
"name": "AcmeDemoBundle",
"dependencies": {
"jquery": "~1.8.2"
}
}
• Optionally set the right permissions to src/Acme/DemoBundle/Resources/public/components
• app/console sp:bower:install
Running app/console cache:clear
results in;
[Sp\BowerBundle\Bower\Exception\RuntimeException]
Dependency cache keys not yet generated, run "app/console sp:bower:install" to initiate the cache: Cached dependencies for "/Users/rvanlaarhoven/Sites/bowertest/app/cache/de_/sp_bower" not found, create it with the method createDependencyMappingCache().
Running phpunit -c app
results in;
Configuration read from /Users/rvanlaarhoven/Sites/bowertest/app/phpunit.xml.dist
FE
Time: 572 ms, Memory: 20.50Mb
There was 1 error:
1) Acme\DemoBundle\Tests\Controller\DemoControllerTest::testSecureSection
LogicException: The request was not redirected.
/Users/rvanlaarhoven/Sites/bowertest/vendor/symfony/symfony/src/Symfony/Component/BrowserKit/Client.php:487
/Users/rvanlaarhoven/Sites/bowertest/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php:26
--
There was 1 failure:
1) Acme\DemoBundle\Tests\Controller\DemoControllerTest::testIndex
Failed asserting that 0 is greater than 0.
/Users/rvanlaarhoven/Sites/bowertest/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php:15
FAILURES!
Tests: 2, Assertions: 1, Failures: 1, Errors: 1.
With the following (parts of it) in my test.log;
[2014-04-02 00:14:06] event.DEBUG: Notified event "bower.pre_exec" to listener "Sp\BowerBundle\EventListener\ExecListener::onPreExec". [] []
[2014-04-02 00:14:06] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException". [] []
[2014-04-02 00:14:06] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException". [] []
[2014-04-02 00:14:06] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Config\Exception\FileLoaderLoadException: "Cannot import resource "." from "/Users/rvanlaarhoven/Sites/bowertest/app/cache/test/assetic/routing.yml". (Dependency cache keys not yet generated, run "app/console sp:bower:install" to initiate the cache: Cached dependencies for "/Users/rvanlaarhoven/Sites/bowertest/app/cache/test/sp_bower" not found, create it with the method createDependencyMappingCache().)" at /Users/rvanlaarhoven/Sites/bowertest/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php line 100 {"exception":"[object] (Symfony\\Component\\Config\\Exception\\FileLoaderLoadException: Cannot import resource \".\" from \"/Users/rvanlaarhoven/Sites/bowertest/app/cache/test/assetic/routing.yml\". (Dependency cache keys not yet generated, run \"app/console sp:bower:install\" to initiate the cache: Cached dependencies for \"/Users/rvanlaarhoven/Sites/bowertest/app/cache/test/sp_bower\" not found, create it with the method createDependencyMappingCache().) at /Users/rvanlaarhoven/Sites/bowertest/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php:100, Sp\\BowerBundle\\Bower\\Exception\\RuntimeException: Dependency cache keys not yet generated, run \"app/console sp:bower:install\" to initiate the cache: Cached dependencies for \"/Users/rvanlaarhoven/Sites/bowertest/app/cache/test/sp_bower\" not found, create it with the method createDependencyMappingCache(). at /Users/rvanlaarhoven/Sites/bowertest/vendor/sp/bower-bundle/Sp/BowerBundle/Assetic/BowerResource.php:102)"} []
.. and a little later in the log from the same test-run;
[2014-04-02 00:14:06] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". [] []
[2014-04-02 00:14:06] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] []
[2014-04-02 00:14:06] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException". [] []
[2014-04-02 00:14:06] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException". [] []
[2014-04-02 00:14:06] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException: "Circular reference detected in "." ("." > ".")." at /Users/rvanlaarhoven/Sites/bowertest/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php line 77 {"exception":"[object] (Symfony\\Component\\Config\\Exception\\FileLoaderImportCircularReferenceException: Circular reference detected in \".\" (\".\" > \".\"). at /Users/rvanlaarhoven/Sites/bowertest/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php:77)"} []
Thanks for looking into it!
Ok i actually used the install_on_warmup: true
config as a workaround to avoid the issue, so I could keep on working. But now I also get the Exception after running cache:clear while install_on_warmup is set to true... So it looks like you fixed it the other way around :)
Damn it :) will fix this in the next days, sorry for the delay
I just pushed some changes to the master branch where I refactored the event dispatching. This should fix the issue with the missing cache. Let me know if you have any more issues.
Yes! This works perfectly. Thanks a lot!
Cache clears normally & tests pass again :)
I had the same problem of others users. The commands cache:clear
and sp:bower:install
normally work fine. The content of the cache files is:
0
a:6:{s:8:"endpoint";a:3:{s:4:"name";s:22:"cycle-bootstrap-bundle";s:6:"source";
... hidden content ...
s:6:"update";a:2:{s:6:"target";s:5:"3.3.4";s:6:"latest";s:5:"3.3.4";}}}s:12:"nrDependants";i:0;s:8:"versions";a:0:{}}
0
i:1;
My app/config/config.yml
file:
# SpBowerBundle Configuration
sp_bower:
install_on_warmup: true
bundles:
CycleBootstrapBundle: ~
When I open the application on browser. I get 3 errors:
I tried change the bower.json and cache location. Also I debugged the application and saw that the cache key is different of the generated cache. I tested with the versions 0.10 and 0.11.
Is there a problem moving the cache files to app/cache? It should't huh? because they are not deleted with
cache:clear
.I'm using a config.yml section like this:
So,
sp:bower:install
runs smoothly but creates an app/cache/de_ folder, and if I try to clear the cache I get this:The
de_
environment? Thanks in advice