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.

Michi
  • 2,480
  • 3
  • 28
  • 38
  • It may be helpful if you could provide the lines where assetic is used in your project. – cheesemacfly Mar 18 '13 at 14:58
  • @cheesemacfly You mean from within the Twig templates? – Michi Mar 18 '13 at 15:04
  • If you use them only in your twig templates then yes! (at least on the one where you are having the problem) – cheesemacfly Mar 18 '13 at 15:05
  • @cheesemacfly It's working again after re-installation of the whole domain on the server. – Michi Mar 18 '13 at 15:07
  • I am still surprised the assetic tries to process a Makefile. Is it intended? – cheesemacfly Mar 18 '13 at 15:10
  • @cheesemacfly no, it's not intended... it surprised me too. I supposed that it processes everything in the asset directory – Michi Mar 18 '13 at 15:13
  • Failing again... I tested in dev mode before and that worked... now trying with --env=prod and failing again – Michi Mar 18 '13 at 15:15
  • You know where is this Makefile? Can you post the assetic code you suspect process it? – cheesemacfly Mar 18 '13 at 15:17
  • 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. – Michi Mar 18 '13 at 15:19
  • Are you running the command with full rights on the folder/subfolders? – cheesemacfly Mar 18 '13 at 15:26
  • @cheesemacfly Yep.. to make sure I tried using root user... but didn't help – Michi Mar 18 '13 at 15:37
  • Hard to say then...can you show us your twig templates concerned sections and config? – cheesemacfly Mar 18 '13 at 16:02
  • @cheesemacfly Updated my question with config.yml – Michi Mar 18 '13 at 16:13
  • Was your project started with Symfony 2.0 and the upgraded to 2.1? – cheesemacfly Mar 18 '13 at 16:47
  • @cheesemacfly 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? – Michi Mar 18 '13 at 17:28
  • 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: http://symfony.com/doc/2.1/reference/configuration/assetic.html – cheesemacfly Mar 18 '13 at 18:26
  • @cheesemacfly Have tried it but still the same problem :-( – Michi Mar 18 '13 at 19:54
  • Can you track down on which template this error happens and post the code here? – cheesemacfly Mar 18 '13 at 20:01
  • @cheesemacfly The error happens on assets that are not used in any template – Michi Mar 18 '13 at 20:14
  • 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? – cheesemacfly Mar 18 '13 at 20:37
  • @cheesemacfly Just did a project wide search and no result for aws.png :-( – Michi Mar 19 '13 at 08:31
  • 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. – Michi Mar 19 '13 at 08:37
  • In my previous search I had cache files excluded... when I include them there are 2 results... I add that to my question. – Michi Mar 19 '13 at 09:08
  • I really don't know this bundle but what if you delete it as a test? What and where are you using it for? – cheesemacfly Mar 19 '13 at 16:09
  • @cheesemacfly Will try and delete it. The bundle is for usage of require.js... AMD style loading of javascript. – Michi Mar 20 '13 at 09:27
  • @cheesemacfly 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 :-( – Michi Mar 20 '13 at 10:12
  • 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? – cheesemacfly Mar 20 '13 at 19:20
  • @cheesemacfly I'm not yet using any filters in the project... will update my question to show usage of the "bad" bundle – Michi Mar 21 '13 at 09:40
  • Something with permission maybe ? – Dickriven Chellemboyee Apr 01 '13 at 19:19
  • @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 :-( – Michi Apr 02 '13 at 04:38

3 Answers3

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
Daniel P
  • 2,439
  • 3
  • 20
  • 27
  • Hi @daniel-p. Capifony uses a newly created cache directory for each deploy... so that can't be it. – Michi Jul 02 '13 at 11:28
  • it's not cleared... the whole project goes into a newly created directory which is then symlinked... therefor the cache directory is also new. – Michi Jul 05 '13 at 09:04
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

Kioko Kiaza
  • 1,378
  • 8
  • 28
  • 57
  • 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. – Michi Apr 12 '13 at 04:00
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

Mirza Selimovic
  • 1,669
  • 15
  • 18
  • Hi @mirza-selimovich. It's not about permissions as I tried executing as root and the same happened... see my updates! – Michi Oct 29 '13 at 15:46