使用assetic时的资产异常:使用symfony2转储和指南针

时间:2011-11-07 13:12:42

标签: symfony compass-sass assetic

我使用scss的@import语句将一些scss文件导入到更大的文件中。尝试转储资产时,我得到以下异常:

$ php app/console assetic:dump --force --verbose
Dumping all dev assets.
Debug mode is on.
[file+] sf_project/app/../web/js/f389f05.js
        sf_project/src/Theaterjobs/MainBundle/Resources/public/js/jquery-1.6.3.min.js
[file+] sf_project/app/../web/js/f389f05_jquery-1.6.3.min_1.js
        sf_project/src/Theaterjobs/MainBundle/Resources/public/js/jquery-1.6.3.min.js
[file+] sf_project/app/../web/css/e9b81fe.css
        sf_project/src/Theaterjobs/MainBundle/Resources/assets/css/_base.scss
        sf_project/src/Theaterjobs/MainBundle/Resources/assets/css/_structure.scss
        sf_project/src/Theaterjobs/MainBundle/Resources/assets/css/theaterjobs.scss

  [RuntimeException]  

Exception trace:
 () at sf_project/vendor/assetic/src/Assetic/Filter/CompassFilter.php:278
 Assetic\Filter\CompassFilter->filterLoad() at sf_project/vendor/assetic/src/Assetic/Filter/FilterCollection.php:62
 Assetic\Filter\FilterCollection->filterLoad() at sf_project/vendor/assetic/src/Assetic/Asset/BaseAsset.php:83
 Assetic\Asset\BaseAsset->doLoad() at sf_project/vendor/assetic/src/Assetic/Asset/FileAsset.php:57
 Assetic\Asset\FileAsset->load() at sf_project/vendor/assetic/src/Assetic/Asset/BaseAsset.php:92
 Assetic\Asset\BaseAsset->dump() at sf_project/vendor/assetic/src/Assetic/Asset/AssetCollection.php:97
 Assetic\Asset\AssetCollection->dump() at sf_project/vendor/bundles/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:206
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->doDump() at sf_project/vendor/bundles/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:163
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->dumpAsset() at sf_project/vendor/bundles/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:62
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->execute() at sf_project/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:214
 Symfony\Component\Console\Command\Command->run() at sf_project/vendor/symfony/src/Symfony/Component/Console/Application.php:194
 Symfony\Component\Console\Application->doRun() at sf_project/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at sf_project/vendor/symfony/src/Symfony/Component/Console/Application.php:118
 Symfony\Component\Console\Application->run() at sf_project/app/console:16

路径因可读性而缩短:)

我们的config.yml看起来像这样

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        cssrewrite: ~
        sass:
          bin: /usr/local/bin/sass
        compass:
          bin: /usr/local/bin/compass
        yui_js:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.6.jar"

我使用

包含样式表
{% stylesheets filter="compass,cssrewrite" '@TheaterjobsMainBundle/Resources/assets/css/*' %}
    <link rel="stylesheet" href="{{ asset_url }}" type="text/css" media="screen" charset="utf-8" />
{% endstylesheets %}

我不知道最近发生了什么。我会抛弃任何可能有助于解决此问题的输出。

谢谢!

2 个答案:

答案 0 :(得分:1)

事实证明,我将样式表包含'@TheaterjobsMainBundle/Resources/assets/css/*'(在路径中使用通配符),而不是直接链接到使用@import导入所有scss部分的主scss文件。

所以sf也试图编译部分因为未设置的变量而失败。

不清除缓存也没有用,或者:)

答案 1 :(得分:0)

我认为当Compass进程无法执行或无法正确完成时会抛出异常。你确定你的罗盘路径是正确的吗?我认为这是你在那里的默认值,但根据你的系统,它可能会有所不同。例如,在Ubuntu Server 11.04上,我的SCSS路径是:

sass: /var/lib/gems/1.8/bin/sass

因此,请确保指南针实际位于/usr/local/bin/compass而不是其他地方。