我总是使用Linux操作系统,但我需要在Windows下检查其他人的操作。 我已经建立了一个 xampp 包和一个 symfony2 框架。
config.yml:
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
write_to: %kernel.root_dir%/../../html/
#bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite : ~
sass :
bin: "C:Rubybinsass"
compass :
bin: "C:Rubybincompass"
yui_css:
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar"
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar"
closure:
jar: "%kernel.root_dir%/Resources/java/compiler.jar"
错误信息:
[exception] 500 | Internal Server Error | AsseticExceptionFilterException
[message] An error occurred while running:
"C:Rubybinruby.EXE" "C:Rubybincompass" "compile" "C:UsersuserAppDataLocalTemp" "--boring" "--config" "C:UsersuserAppDataLocalTempass1047.tmp" "--sass-dir" "" "--css-dir" "" "C:/Users/user/AppData/Local/Temp/ass1048.tmp.sass"
Error Output:
Individual stylesheets must be in the sass directory.
我无法理解"单个样式表必须在 sass 目录中"错误。
如何在Windows上的Symfony2中设置指南针?
版本信息:
- 窗户 : 7
- 红宝石 : 2.1.5
- 萨斯 : 3.4.10
- 指南针 : 1.0.3
编辑:kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php
约312线
$pb->add('--sass-dir')->add('')->add('--css-dir')->add('');
自
$pb->add('--sass-dir')->add($tempDir)->add('--css-dir')->add($tempDir);
和 YuiCompressor-2.4.8.jar更改为 YuiCompressor-2.4.7.jar。
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
write_to: %kernel.root_dir%/../../html/
#bundles: [ ]
java: C:Program Files (x86)Javajre1.8.0_31binjava.exe
ruby: C:Rubybinruby.exe
filters:
cssrewrite : ~
sass :
bin: C:Rubybinsass
compass :
bin: C:Rubybincompass
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
yui_css:
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
这在执行 assetic:dump 时对我有用 - 但是,在开发服务器 (Windows) 中打开站点时,我仍然收到此错误 - 即使在清理缓存后也是如此。我修补了CompassFilter.php以保留Temp-Files。这导致两个文件都正确创建,但没有编译的 CSS。将整个命令粘贴到 Shell 会创建 CSS。因此,这不起作用的唯一原因必须是用户权限或环境变量的问题。
仔细观察FilterCompass.php第341-345行,发现了一个奇怪的补丁,将HOME-Directory设置为Windows Temp-Dir。我删除了整个块
if ($this->homeEnv) {
// it's not really usefull but... https://github.com/chriseppstein/compass/issues/376
$pb->setEnv('HOME', FilesystemUtils::getTemporaryDirectory());
$this->mergeEnv($pb);
}
一切都很好。