Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony assetic:dump runtime exception

I'm stepping into deploying my Symfony app using Capifony. When Capifony executes assetic:dump I get a runtime Exception.

[RuntimeException]
Unable to write file {path}/releases/20130314071536/app/../web/js/.

I tried executing the command manually and get the same Exception.
Then I tried the command using the --verbose parameter and realized that all files with a source path that has a dot in it where written without the file name, only the extension. The Exception comes up when hitting a file name with no extension (Makefile in this case) and trying to write the file "." (only a dot).

On another domain on the same server I have the exactly same code but deployed manually. There I don't get this error. So it can't be a problem with PHP version. I also checked Assetic and Assetic-Bundle versions and they are the same.

What could be the cause of assetic working different?

EDIT:
I forgot to mention that it also works correctly on my development machine.

EDIT 2:
It starts failing on file

EDIT 3:
I just realized that it works fine for dev environment... but for --env=prod it gives the problem arises

web/bundles/assets/assets/images/icons/aws.png

a file I'm not using in any template

Stacktrace from the error

Exception trace:
 () at /home/yanic.info/domains/pe.yanic.info/public_html/releases/20130318143912/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:249
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->doDump() at /home/yanic.info/domains/pe.yanic.info/public_html/releases/20130318143912/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:187
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->dumpAsset() at /home/yanic.info/domains/pe.yanic.info/public_html/releases/20130318143912/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:64
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->execute() at /home/yanic.info/domains/pe.yanic.info/public_html/releases/20130318143912/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:238
 Symfony\Component\Console\Command\Command->run() at /home/yanic.info/domains/pe.yanic.info/public_html/releases/20130318143912/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:192
 Symfony\Component\Console\Application->doRun() at /home/yanic.info/domains/pe.yanic.info/public_html/releases/20130318143912/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:78
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/yanic.info/domains/pe.yanic.info/public_html/releases/20130318143912/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:105
 Symfony\Component\Console\Application->run() at /home/yanic.info/domains/pe.yanic.info/public_html/releases/20130318143912/app/console:33

config.yml

# Twig Configuration
twig:
    debug:            %kernel.debug%
    strict_variables: %kernel.debug%
    form:
        resources: [HomeBundle:Form:fields.html.twig]
# Assetic Configuration
assetic:
    write_to: "%kernel.root_dir%/../web"
    debug:          %kernel.debug%
    use_controller: false
    bundles:        ['YanicSecurityBundle','HomeBundle','UsersBundle','CmsBundle','AssetsBundle','FormBundle','TranslationBundle','EventBundle','ShopBundle','NewsletterBundle','IssueBundle','ProjectBundle']
    filters:
        cssrewrite: ~

EDIT 4:
When searching for aws.png (the first result to be broken) there are 2 results inside the cache files:

/Applications/MAMP/htdocs/symfony-standard-2.1/app/cache/dev/appDevUrlGenerator.php:
  112          '_assetic_e4d7f8d' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => 'e4d7f8d',    'pos' => NULL,    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/assets/images/icons/arrow_rotate_clockwise.png',    ),  ),),
  113          '_assetic_e4d7f8d_0' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => 'e4d7f8d',    'pos' => '0',    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/assets/images/icons/arrow_rotate_clockwise_arrow_rotate_clockwise_1.png',    ),  ),),
  114:         '_assetic_e1ec2e3' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => 'e1ec2e3',    'pos' => NULL,    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/assets/images/icons/aws.png',    ),  ),),
  115          '_assetic_e1ec2e3_0' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => 'e1ec2e3',    'pos' => '0',    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/assets/images/icons/aws_aws_1.png',    ),  ),),
  116          '_assetic_490c282' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => '490c282',    'pos' => NULL,    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/assets/images/icons/cancel.png',    ),  ),),
  ...
  874          '_assetic_13192a1' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => '13192a1',    'pos' => NULL,    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/images/icons/arrow_rotate_clockwise.png',    ),  ),),
  875          '_assetic_13192a1_0' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => '13192a1',    'pos' => '0',    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/images/icons/arrow_rotate_clockwise_arrow_rotate_clockwise_1.png',    ),  ),),
  876:         '_assetic_3d6d4c9' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => '3d6d4c9',    'pos' => NULL,    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/images/icons/aws.png',    ),  ),),
  877          '_assetic_3d6d4c9_0' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => '3d6d4c9',    'pos' => '0',    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/images/icons/aws_aws_1.png',    ),  ),),
  878          '_assetic_5ea17b1' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'assetic.controller:render',    'name' => '5ea17b1',    'pos' => NULL,    '_format' => 'png',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/js/images/icons/cancel.png',    ),  ),),

/Applications/MAMP/htdocs/symfony-standard-2.1/app/cache/dev/appDevUrlMatcher.php:
  517  
  518          // _assetic_e1ec2e3
  519:         if ($pathinfo === '/js/assets/images/icons/aws.png') {
  520              return array (  '_controller' => 'assetic.controller:render',  'name' => 'e1ec2e3',  'pos' => NULL,  '_format' => 'png',  '_route' => '_assetic_e1ec2e3',);
  521          }
  ...
 4327  
 4328          // _assetic_3d6d4c9
 4329:         if ($pathinfo === '/js/images/icons/aws.png') {
 4330              return array (  '_controller' => 'assetic.controller:render',  'name' => '3d6d4c9',  'pos' => NULL,  '_format' => 'png',  '_route' => '_assetic_3d6d4c9',);
 4331          

EDIT 5:
As recommended by @cheesemacfly I removed the hearsay_require_js bundle and the issue is gone. Now that I know what to blame for the error, I'd need to know why it does only happen on the staging server and when deploying with Capifony.

like image 214
Michi Avatar asked Mar 14 '13 09:03

Michi


1 Answers

Try recreating your cache directories.

You can get all sort of weird behaviour when your cache is out-of-sync.

To clear your cache:

rm -rf app/cache/*

sudo chmod +a "www-data allow delete,write,append,file_inherit,directory_inherit" app/cache
sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache

or

rm -rf app/cache/*

sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache
like image 50
Daniel P Avatar answered Oct 05 '22 23:10

Daniel P