37

I have installed compass in my symfony 2 project. Now i want to use the assetic filter in combination with compass. i am using windows 7.

I think it's almost working but i am still getting this error :

[Assetic\Exception\FilterException]
An error occurred while running:
"C:\Ruby21-x64\bin\ruby.EXE" "C:\Ruby21-x64\bin\compass.BAT" "compile" "C:\
Users\tommie\AppData\Local\Temp" "--boring" "--config" "C:\Users\tommie\App
Data\Local\Temp\ass4325.tmp" "--sass-dir" "" "--css-dir" "" "C:/Users/tommi
e/AppData/Local/Temp/ass4326.tmp.scss"
Error Output:
C:/Ruby21-x64/bin/compass.BAT:1: syntax error, unexpected tCONSTANT, expect
ing end-of-input

My code in html (twig) : stylesheets.html.twig

{% stylesheets filter="compass" output='css/compiled/*.css'
   "@AcmeSassDemoBundle/Resources/assets/css/base.scss"
%}
<link rel="stylesheet" href="{{ asset_url }}" />

{% endstylesheets %}

base.html.twig:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>{% block title %}Sass Demo!{% endblock %}</title>
    {#{% block stylesheets %}{% endblock %} #}

    {% include "AcmeSassDemoBundle:Demo:stylesheets.html.twig" %}
    <link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />
</head>
<body>
    <div id="header">
        {% block header %}
            <h1>Sass Demo</h1>
            <div class="logo">this container is half as big as the sass.gif's dimension</div>
        {% endblock %}
    </div>

    <div id="menu">
        <ul>
            <li class="add"><a href="#">add something</a></li>
            <li class="edit"><a href="#">edit something</a></li>
            <li class="delete"><a href="#">delete something</a></li>
        </ul>
    </div>

    <div id="content">
        {% block body %}hello sass!{% endblock %}
    </div>

    <div id="footer">
        {% block footer %}awesome footer goes here ...{% endblock %}
    </div>
    {% block javascripts %}{% endblock %}</
</body>

index.html.twig:

{% extends 'AcmeSassDemoBundle:Demo:base.html.twig' %}

{% block body %}

<div class="content">
  hello world
    <div class="sub">
       This text should be in green ...
       <div class="sub">
        ... and this one in blue!
    </div>
</div>

my config.yml filter assetic configuration:

# Assetic Configuration
assetic:
    debug: false
    use_controller: true# default: true
    filters:
        sass:    ~
        compass: 
            compass:
                bin: C:\Ruby21-x64\bin\compass.bat

base.scss

$main-background-color: #FFF;
$main-color: #FFF;
$light-color: #759E1A;
$link-color: #0088CC;

body {
    background-color: #CCC;
}

@mixin rounded($side, $radius: 10px) {
    border-radius: $radius;
    border-#{$side}-radius: $radius;
    -moz-border-radius-#{$side}: $radius;
    -webkit-border-#{$side}-radius: $radius;
}

@import "header.scss";
@import "menu.scss";
@import "content.scss";
@import "footer.scss";
Thomas Crawford
  • 886
  • 2
  • 15
  • 45
  • Is it a typo or do you have 2 times `compass` in your config? I only have one in mine. Try to remove one [like so](https://gist.github.com/ferdynator/280048aceea4ea16d925). Also could you please add your `base.scss`? – ferdynator Apr 14 '15 at 10:31
  • Hi ferdynator, updated my question and added base.scss. Also tried your config but still not working. error : "/usr/bin/ruby" "C:\Ruby21-x64\bin\compass.bat" "compile" "C:\Windows\Temp" "--boring" "--config" "C:\Windows\Temp\assB498.tmp" "--sass-dir" "" "--css-dir" "" "C:/Windows/Temp/assB499.tmp.scss" – Thomas Crawford Apr 15 '15 at 09:43
  • take a look at this guide maybe it will help: http://stackoverflow.com/questions/16003621/configuring-compass-on-windows – Nickolaus Apr 17 '15 at 20:54
  • Can you show us the content of compass.BAT? It seems that this file contains an error. – kronn Jul 01 '16 at 08:04

2 Answers2

1

I don`t want to discourage you, but using Windows and Ruby this is the worse combo ever, (node also, node_module with long tree subdirectories, making Windows to have a limit of 256charaters and will show an error by installing the packages). My point is like an alternative to move your project to Virtual Machine similar with your server configuration. (VirtualBox and Vagrant)

Linux is more friendly with Ruby (it has support for him) and has symlinks and long path names;

for tinkering: https://symfony.com/doc/2.8/setup/homestead.html

Perhaps will be help also this old link: How to use SCSS filter in Symfony2 under Windows?

0

It's highly likely this is something you've already tried / noticed, but just in case:

The error seems more like the ruby interpreter is dying, rather than it choking on your scss / twig. Which makes some degree of sense since ruby doesn't expect a .BAT script to be utilized.

Generally just 'compass' is used, not 'compass.BAT', which usually just calls ruby with 'compass'.

I.e.

"C:\Ruby21-x64\bin\ruby.EXE" "C:\Ruby21-x64\bin\compass.BAT" "compile" "C:\ Users\tommie\AppData\Local\Temp" "--boring" "--config" "C:\Users\tommie\App Data\Local\Temp\ass4325.tmp" "--sass-dir" "" "--css-dir" "" "C:/Users/tommi e/AppData/Local/Temp/ass4326.tmp.scss"

Would normally be

"C:\Ruby21-x64\bin\ruby.EXE" "C:\Ruby21-x64\bin\compass" "compile" "C:\ Users\tommie\AppData\Local\Temp" "--boring" "--config" "C:\Users\tommie\App Data\Local\Temp\ass4325.tmp" "--sass-dir" "" "--css-dir" "" "C:/Users/tommi e/AppData/Local/Temp/ass4326.tmp.scss"

Essentially, set the compass.bin path to not have the .bat in it, and you'll probably be fine. This is generally in the assetic.filters.compass.bin in your config.yml

See also https://github.com/symfony/AsseticBundle/issues/158

This also reveals special characters aren't well liked, not sure how well it likes spaces in dirnames. Those might also contribute to choking if it still doesn't work without the .bat