Symfony assetic:dump runtime exception
Asked Answered
K

3

8

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.

Kannada answered 14/3, 2013 at 9:19 Comment(30)
It may be helpful if you could provide the lines where assetic is used in your project.Plummy
@Plummy You mean from within the Twig templates?Kannada
If you use them only in your twig templates then yes! (at least on the one where you are having the problem)Plummy
@Plummy It's working again after re-installation of the whole domain on the server.Kannada
I am still surprised the assetic tries to process a Makefile. Is it intended?Plummy
@Plummy no, it's not intended... it surprised me too. I supposed that it processes everything in the asset directoryKannada
Failing again... I tested in dev mode before and that worked... now trying with --env=prod and failing againKannada
You know where is this Makefile? Can you post the assetic code you suspect process it?Plummy
The file is web/bundles/assets/assets/vendors/moment/Makefile but I'm not using it in any template. Will update my answer with the stacktrace from the error.Kannada
Are you running the command with full rights on the folder/subfolders?Plummy
@Plummy Yep.. to make sure I tried using root user... but didn't helpKannada
Hard to say then...can you show us your twig templates concerned sections and config?Plummy
@Plummy Updated my question with config.ymlKannada
Was your project started with Symfony 2.0 and the upgraded to 2.1?Plummy
@Plummy Yes, but it's quite some time ago that I've upgraded. But always worth checking if there's something left. What should I look at?Kannada
Really not sure but I would say the use_controller: false section of your config.yml file should more look like the one in here: symfony.com/doc/2.1/reference/configuration/assetic.htmlPlummy
@Plummy Have tried it but still the same problem :-(Kannada
Can you track down on which template this error happens and post the code here?Plummy
@Plummy The error happens on assets that are not used in any templateKannada
Nowhere in your code you or on of the bundle you have installed are using this aws.png file? What if you run a search in all files of your project?Plummy
@Plummy Just did a project wide search and no result for aws.png :-(Kannada
Could it be that some Extension is interfering? I just realized that the files that are wrong are those that hearsay_require_js puts there.Kannada
In my previous search I had cache files excluded... when I include them there are 2 results... I add that to my question.Kannada
I really don't know this bundle but what if you delete it as a test? What and where are you using it for?Plummy
@Plummy Will try and delete it. The bundle is for usage of require.js... AMD style loading of javascript.Kannada
@Plummy Removed the extension and now the problem is gone. It's good to know, but I need that bundle so still need to solve the problem :-(Kannada
Can the fact that it happens in only a specific environment be linked to the usage of ? like in filter='?yourfilter' or you don't have anywhere in your project this kind of code? Can you show use an example of usage you have with this bundle?Plummy
@Plummy I'm not yet using any filters in the project... will update my question to show usage of the "bad" bundleKannada
Something with permission maybe ?Lutz
@Chellem That was my first thought, but everything is deployed using the same user. To make sure I executed the command as root user and it didn't make any difference :-(Kannada
S
2

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
Spotlight answered 2/7, 2013 at 11:23 Comment(2)
Hi @daniel-p. Capifony uses a newly created cache directory for each deploy... so that can't be it.Kannada
it's not cleared... the whole project goes into a newly created directory which is then symlinked... therefor the cache directory is also new.Kannada
I
0

check your permissions, it seems you have no write permissions on

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

look here: http://symfony.com/doc/2.0/book/installation.html Setting up Permissions section.

One question...

Can you upload your deploy.rb config? did you set user, root mode ...?

You can also be more verbose by uncommenting the following line

logger.level = Logger::MAX_LEVEL

you will see step by step the deployment

Ice answered 11/4, 2013 at 12:45 Comment(1)
It's not a permission problem as I tried to execute as root and same problem. Also the main problem is that the command removes the file names leaving only the extension.Kannada
P
0

Like the other users said, it's a problem with the permissions.

rm -rf symfonyProject/app/cache/*

chmod -R 755 symfonyProject/

chmod -R 777 symfonyProject/app/cache/

chmod -R 777 symfonyProject/app/logs/

Hope it helps

Promisee answered 29/10, 2013 at 13:27 Comment(1)
Hi @mirza-selimovich. It's not about permissions as I tried executing as root and the same happened... see my updates!Kannada

© 2022 - 2024 — McMap. All rights reserved.