assetic:dump失败,显示“.pull-right is undefined:line:60”

时间:2013-09-27 19:58:16

标签: symfony twitter-bootstrap-3 symfony-2.3 assetic lessphp

我试图在本地安装glyphicons,而不是从CDN(已经停止显示它们,因为我没有调查的原因)拉出来。现在运行assetic:dump导致异常我不知道如何修复:

me@server:/var/www/blah$ php app/console assetic:dump -vvv
Dumping all dev assets.
Debug mode is on.

20:26:32 [file+] /var/www/blah/app/../web/fonts/glyphicons-halflings-regular.eot
        /var/www/blah/app/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.eot
20:26:32 [file+] /var/www/blah/app/../web/fonts/glyphicons-halflings-regular_glyphicons-halflings-regular_1.eot
        /var/www/blah/app/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.eot
20:26:32 [file+] /var/www/blah/app/../web/fonts/glyphicons-halflings-regular.svg
        /var/www/blah/app/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.svg
20:26:32 [file+] /var/www/blah/app/../web/fonts/glyphicons-halflings-regular_glyphicons-halflings-regular_1.svg
        /var/www/blah/app/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.svg
20:26:32 [file+] /var/www/blah/app/../web/fonts/glyphicons-halflings-regular.ttf
        /var/www/blah/app/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.ttf
20:26:32 [file+] /var/www/blah/app/../web/fonts/glyphicons-halflings-regular_glyphicons-halflings-regular_1.ttf
        /var/www/blah/app/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.ttf
20:26:32 [file+] /var/www/blah/app/../web/fonts/glyphicons-halflings-regular.woff
        /var/www/blah/app/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.woff
20:26:32 [file+] /var/www/blah/app/../web/fonts/glyphicons-halflings-regular_glyphicons-halflings-regular_1.woff
        /var/www/blah/app/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.woff
20:26:32 [file+] /var/www/blah/app/../web/css/bootstrap.css
        /var/www/blah/app/../vendor/twbs/bootstrap/less/bootstrap.less

  [Exception]
  .pull-right is undefined: line: 60

Exception trace:
 () at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:3465
 lessc_parser->throwError() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:2008
 lessc->throwError() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:685
 lessc->compileProp() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:282
 lessc->compileProps() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:220
 lessc->compileCSSBlock() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:194
 lessc->compileBlock() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:656
 lessc->compileProp() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:282
 lessc->compileProps() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:220
 lessc->compileCSSBlock() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:194
 lessc->compileBlock() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:656
 lessc->compileProp() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:282
 lessc->compileProps() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:235
 lessc->compileMedia() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:197
 lessc->compileBlock() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:656
 lessc->compileProp() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:160
 lessc->compileImportedProps() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:766
 lessc->compileProp() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:282
 lessc->compileProps() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:276
 lessc->compileRoot() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:191
 lessc->compileBlock() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:1810
 lessc->compile() at /var/www/blah/vendor/leafo/lessphp/lessc.inc.php:1937
 lessc->parse() at /var/www/blah/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessphpFilter.php:104
 Assetic\Filter\LessphpFilter->filterLoad() at /var/www/blah/vendor/kriswallsmith/assetic/src/Assetic/Filter/FilterCollection.php:62
 Assetic\Filter\FilterCollection->filterLoad() at /var/www/blah/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php:90
 Assetic\Asset\BaseAsset->doLoad() at /var/www/blah/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php:65
 Assetic\Asset\FileAsset->load() at /var/www/blah/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php:99
 Assetic\Asset\BaseAsset->dump() at /var/www/blah/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php:151
 Assetic\Asset\AssetCollection->dump() at /var/www/blah/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:222
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->doDump() at /var/www/blah/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:162
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->dumpAsset() at /var/www/blah/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:61
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->execute() at /var/www/blah/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:244
 Symfony\Component\Console\Command\Command->run() at /var/www/blah/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:904
 Symfony\Component\Console\Application->doRunCommand() at /var/www/blah/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at /var/www/blah/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/blah/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
 Symfony\Component\Console\Application->run() at /var/www/blah/app/console:27

assetic:dump [--watch] [--force] [--period="..."] [write_to]

config.yml包括:

assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        cssrewrite: ~

        lessphp:
            apply_to: "\.less$"
            file:     "%kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php"
    assets:
        fonts_glyphicons_eot:
            inputs:
                - "%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.eot"
            output: "fonts/glyphicons-halflings-regular.eot"
        fonts_glyphicons_svg:
            inputs:
                - "%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.svg"
            output: "fonts/glyphicons-halflings-regular.svg"
        fonts_glyphicons_ttf:
            inputs:
                - "%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.ttf"
            output: "fonts/glyphicons-halflings-regular.ttf"
        fonts_glyphicons_woff:
            inputs:
                - "%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.woff"
            output: "fonts/glyphicons-halflings-regular.woff"
        css_bootstrap:
            inputs:
                -  "%kernel.root_dir%/../vendor/twbs/bootstrap/less/bootstrap.less"
            output: "css/bootstrap.css"
            filters:
                - lessphp
        js_bootstrap:
            inputs:
                -  "%kernel.root_dir%/../vendor/twbs/bootstrap/js/*.js"
            output: "js/bootstrap.js"

composer.json包括:

"require": {
    "twbs/bootstrap": "v3.0.0",
    "components/jquery": "1.10.2",
    "leafo/lessphp": "0.4.*@dev",
}

非常感谢任何建议!

3 个答案:

答案 0 :(得分:5)

原来这是lessphp中的一个错误:https://github.com/leafo/lessphp/pull/478

目前解决方案是将composer.json中的版本更改为:

"require": {
    "leafo/lessphp": "dev-master#85bd4557920d5f4fcbf41beb621e91b842e3621b"
}

但显然这只是暂时的。感谢freenode上的#symfony中的milka!

答案 1 :(得分:0)

我很确定我遇到了这个问题,并确定是因为Bootstrap LESS在单独的文件中定义了变量,而且Assetic LESS编译器不能很好地使用在不同文件中定义的变量。

答案 2 :(得分:0)

结帐this reported bug on github。看起来最终缺少;的压缩文件会导致此行为。一种解决方案是手动添加它。

我建议的解决方案是使用未压缩的文件来防止这种情况,并在dev环境中提供更易读的代码。对于prod环境,无论如何都会通过资产压缩文件。