8

我正在逐步使用 Capifony 部署我的 Symfony 应用程序。当 Capifony 执行assetic:dump 时,我得到一个运行时异常。

[RuntimeException]
无法写入文件 {path}/releases/20130314071536/app/../web/js/。

我尝试手动执行命令并得到相同的异常。
然后我使用 --verbose 参数尝试了该命令,并意识到所有具有源路径的文件都包含一个点,其中没有文件名,只有扩展名。当遇到没有扩展名的文件名(在本例中为 Makefile)并尝试写入文件“。”时出现异常。(只有一个点)。

在同一台服务器上的另一个域上,我有完全相同的代码,但手动部署。我没有得到这个错误。所以PHP版本不会有问题。我还检查了 Assetic 和 Assetic-Bundle 版本,它们是相同的。

什么可能是资产工作不同的原因?

编辑:
我忘了提到它在我的开发机器上也能正常工作。

编辑2:
它开始在文件上失败

编辑 3:
我刚刚意识到它适用于开发环境......但是对于 --env=prod 它会出现问题

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

我没有在任何模板中使用的文件

来自错误的堆栈跟踪

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

配置.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: ~

编辑 4:
当搜索 aws.png (第一个被破坏的结果)时,缓存文件中有 2 个结果:

/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          

编辑 5:
按照@cheesemacfly 的建议,我删除了hearsay_require_js 捆绑包,问题就消失了。既然我知道该错误应归咎于什么,我需要知道为什么它只发生在登台服务器上以及使用 Capifony 进行部署时。

4

3 回答 3

2

尝试重新创建缓存目录。

当您的缓存不同步时,您可能会遇到各种奇怪的行为。

要清除缓存:

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

或者

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
于 2013-07-02T11:23:21.543 回答
0

就像其他用户说的那样,这是权限的问题。

rm -rf symfonyProject/app/cache/*

chmod -R 755 symfonyProject/

chmod -R 777 symfonyProject/app/cache/

chmod -R 777 symfonyProject/app/logs/

希望能帮助到你

于 2013-10-29T13:27:05.693 回答
0

检查您的权限,您似乎没有写权限

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

看这里:http ://symfony.com/doc/2.0/book/installation.html设置权限部分。

一个问题...

你可以上传你的 deploy.rb 配置吗?您是否设置了用户、root 模式...?

您还可以通过取消注释以下行来更详细

logger.level = Logger::MAX_LEVEL

你会看到一步一步的部署

于 2013-04-11T12:45:04.237 回答