22

This question seems to have been asked multiple times but none of the solutions work for me.

I'm in my prod environment, here is what I've done:

  • cleared cache before/after doing anything
  • attempted commenting out the _assetic stuff in config_dev and ensure it isn't anywhere else (not that this should matter in prod env)
  • set use_controller to both true and false (obviously works with true but doesn't use the compiled files)

Is there anything else I'm missing? The files are generating completely fine from php app/console assetic:dump --env=prod --no-debug the file name matches that of in the error minus the route stuff.

animuson
  • 53,861
  • 28
  • 137
  • 147
greg
  • 6,853
  • 15
  • 58
  • 71
  • 4
    Have you set the `bundles: [MyBundle, MyOtherBundle]` option in `config.yml`? What versions of Assetic and AsseticBundle are you using? – noisebleed Jul 13 '12 at 09:42
  • Thanks for the reply. Nope, haven't set that, what does it achieve? – greg Jul 13 '12 at 17:17
  • Assetic will only search for assets in the bundles specified in `bundles[]`. – noisebleed Jul 13 '12 at 17:24
  • 1
    My app is almost entirely client side, all my assets are linked in app/resources/views/base.html.twig, should I add the bundles parameters without any bundles listed? – greg Jul 13 '12 at 17:58
  • I don't get why it is even trying to load a route in production mode. shouldn't it be trying to load the static file? – greg Jul 13 '12 at 18:07
  • Although this question claims that it has been asked before, the question suggested as a duplicate is not a duplicate as this error happens in `use_controller=true` mode, the linked question is about `use_controller=false` – rjmunro Aug 02 '13 at 22:10
  • do you use APC cache? If you do, clear it :) – M. Foti Oct 01 '13 at 15:53

9 Answers9

50

I had this problem just one minute ago. Clean up the cache worked for me:

app/console cache:clear --env=prod

Hope this helps.

micha149
  • 831
  • 1
  • 9
  • 15
  • 1
    Nope, doesn't work, that was the first thing I tried. Thanks for the answer though, I couldn't solve it so i stopped using assetic and set up a grunt script to compile all my files. – greg Aug 13 '12 at 17:11
  • 10
    IME basic "rm -rf app/cache" seems to be more reliable than the cache:clear or ot:cc app/console commands for some reason. – Marcus Oct 18 '13 at 11:24
  • 2
    @Marcus, thanks I have deleted the cache several times using console commands and the problem persisted, "rm -rf" did the trick!!! – Cesar Sep 02 '14 at 20:50
22

If clearing the cache or dumping the assets doesn't work. Try noisebleed's comment:

// app/config_dev.yml
assetic:
    use_controller: true
    bundles: ['FooBarBundle']
14

Maybe you have removed the assetic routing from the app/routing_dev.yml

_assetic:
    resource: .
    type:     assetic
user3013964
  • 141
  • 1
  • 2
  • I can't believe it's not mentioned in the doc http://symfony.com/doc/current/assetic/asset_management.html – 0x1gene Oct 07 '16 at 14:39
2

Faced with the same issue but reason was I name template as "something.twig", not "something.html.twig".

Its seems assetic not scan templates without .html in extension.

As result - template work, but assetic not perform dumping/adding routes for assets from it. Adding .html solve the problem.

igritsay
  • 21
  • 2
1

Updating the config.yml with a dumb character (newline, white space) remove that error. It seems that by doing that, we force the cache do be re-generated. (Symfony 3.0.0)

Remy Mellet
  • 1,675
  • 20
  • 23
0

maybe is too late but... what worked for me:

php composer.phar install
php app/console cache:clear
php app/console cache:warmup
augustocosta
  • 139
  • 1
  • 2
  • 8
0

Like @Marcus said, if you tried:

php bin/console cache:clear

and it didn't help, please clear the your_project_root/var/cache folder manually (remove all folders and files). If you use unix/linux systems, and receive a system message like "Error removing file: Permission denied", you need to change accesses to dir first, for example you can use console command

sudo chmod -R 0777 /your_site_directory/var/cache/

and after this you can clear cache dir.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Vaha
  • 2,179
  • 2
  • 17
  • 29
0

I encountered this issue in Symfony 3.3 after trying to override my Twig templates directory. Not sure how to fix the issue, but reverting to default templates directory config resolved the issue for now.

# config.yml
twig:
    paths: ["%kernel.project_dir%/templates"] # Remove this line to use default dir
Brooks
  • 151
  • 2
  • 10
0

After trying all the suggested solutions here, to me it was simply the issue with the name of the template. I had .twig but not .html.twig extension, that's all.

gphilip
  • 1,114
  • 15
  • 33