3

I always use a Linux OS, but I need to check the operation under Windows for others. I have set up a xampp package and a symfony2 framework.

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:\Ruby\bin\sass"
        compass     :
            bin: "C:\Ruby\bin\compass"
        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"

error message:

[exception] 500 | Internal Server Error | Assetic\Exception\FilterException
[message] An error occurred while running:
"C:\Ruby\bin\ruby.EXE" "C:\Ruby\bin\compass" "compile" "C:\Users\user\AppData\Local\Temp" "--boring" "--config" "C:\Users\user\AppData\Local\Temp\ass1047.tmp" "--sass-dir" "" "--css-dir" "" "C:/Users/user/AppData/Local/Temp/ass1048.tmp.sass"

Error Output:
Individual stylesheets must be in the sass directory.

I couldn't understand the "Individual stylesheets must be in the sass directory." error.

How do I set the compass in Symfony2 on windows?

Version information:

  • Windows : 7
  • Ruby : 2.1.5
  • Sass : 3.4.10
  • Compass : 1.0.3
cimmanon
  • 67,211
  • 17
  • 165
  • 171
Devatim
  • 331
  • 2
  • 10
  • Did you try searching for the error at all? Possible duplicate: http://stackoverflow.com/questions/19419011/compass-you-must-compile-individual-stylesheets-from-the-project-directory – cimmanon Mar 11 '15 at 12:14

2 Answers2

8

Edit: kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php

around 312 line

$pb->add('--sass-dir')->add('')->add('--css-dir')->add('');

to

$pb->add('--sass-dir')->add($tempDir)->add('--css-dir')->add($tempDir);

and yuicompressor-2.4.8.jar change to 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)\Java\jre1.8.0_31\bin\java.exe
    ruby: C:\Ruby\bin\ruby.exe
    filters:
        cssrewrite  : ~
        sass        :
            bin: C:\Ruby\bin\sass
        compass     :
            bin: C:\Ruby\bin\compass
        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"
Devatim
  • 331
  • 2
  • 10
  • I had to install the full symfony dev stack on a windows environment and it worked fine just with editing kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php as you've suggested (no need of changing the yuicompressor version). Thanks for sharing this! – Żabojad Jun 09 '15 at 14:27
  • This works, but it would be great if we could configure these paths somewhere (editing vendors code sucks...) – ioleo Jan 27 '16 at 12:58
0

This worked for me when doing an assetic:dump - though, when opening the Site in the Dev-Server (Windows) i've still got this error - even after cleaning the Cache. I patched the CompassFilter.php to keep the Temp-Files. Which leads to the fact that both files were created correctly, but there was no compiled CSS. Pasting the whole command to a Shell created the CSS. So the Only Reason this does not work must be a Problem with User Rights or the Environment Variables.

A closer look at FilterCompass.php Line 341 - 345 revealed a strange Patch setting the HOME-Directory to a Windows Temp-Dir. I removed the whole block

if ($this->homeEnv) {
    // it's not really usefull but... https://github.com/chriseppstein/compass/issues/376
    $pb->setEnv('HOME', FilesystemUtils::getTemporaryDirectory());
    $this->mergeEnv($pb);
}

and everything worked fine.