Question

I'm trying out symfony2 and its assetic with compass/sass. But it is an error in the compiled css file when I am only in dev environment:

/*
[exception] 500 | Internal Server Error | Symfony\Component\Debug\Exception\ContextErrorException
[message] Warning: file_put_contents(): Filename cannot be empty in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
[1] Symfony\Component\Debug\Exception\ContextErrorException: Warning: file_put_contents(): Filename cannot be empty in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
    at n/a
        in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312

    at Symfony\Component\Debug\ErrorHandler->handle('2', 'file_put_contents(): Filename cannot be empty', '/Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php', '312', array('asset' => object(FileAsset), 'root' => '/Users/kklaus/Workspace/Symfony/app/../web', 'path' => 'bundles/webdevblog/sass/style.scss', 'loadPaths' => array('/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass'), 'tempDir' => '/private/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T', 'compassProcessArgs' => array('/usr/bin/ruby', '/usr/bin/compass', 'compile', '/private/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T'), 'pb' => object(ProcessBuilder), 'optionsConfig' => array('additional_import_paths' => array('/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass'), 'sass_options' => array('cache_location' => '/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T'), 'http_path' => '/images'), 'config' => array('additional_import_paths = [
    "/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass"
]', 'sass_options = {
    :cache_location => "/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T"
}', 'http_path = "/images"'), 'name' => 'http_path', 'value' => '/images', 'configFile' => false))
        in  line 

    at file_put_contents('', 'additional_import_paths = [
    "/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass"
]
sass_options = {
    :cache_location => "/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T"
}
http_path = "/images"
')
        in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312

    at Assetic\Filter\CompassFilter->filterLoad(object(FileAsset))
        in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/FilterCollection.php line 62

    at Assetic\Filter\FilterCollection->filterLoad(object(FileAsset))
        in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php line 90

    at Assetic\Asset\BaseAsset->doLoad('
body {
  background-color: yellow;
}


h2 {
  color: green;

}

p {
  span {
    font-weight: bold;
  }
}', null)
        in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php line 65

    at Assetic\Asset\FileAsset->load()
        in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php line 99

    at Assetic\Asset\BaseAsset->dump(null)
        in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCache.php line 69

    at Assetic\Asset\AssetCache->dump()
        in /Users/kklaus/Workspace/Symfony/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php line 88

    at Symfony\Bundle\AsseticBundle\Controller\AsseticController->render('56ff856', '0')
        in  line 

    at call_user_func_array(array(object(AsseticController), 'render'), array('56ff856', '0'))
        in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2844

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2818

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2947

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2249

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in /Users/kklaus/Workspace/Symfony/web/app_dev.php line 28


*/

When I'm in the prod environment, it works. The CSS file is correct:

/* line 2, assetic_compass67JtN2.scss */
body {
  background-color: yellow;
}

/* line 7, assetic_compass67JtN2.scss */
h2 {
  color: green;
}

/* line 13, assetic_compass67JtN2.scss */
p span {
  font-weight: bold;
}

Asstetic configuration in config.yml:

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    bundles:        [ ]
    #java: /usr/bin/java
    ruby: /usr/bin/ruby
    filters:
        cssrewrite: ~
        sass:
          bin: /usr/bin/sass
        compass:
          bin: /usr/bin/compass

Do somebody know where is the mistake and why it does not work on dev?

Was it helpful?

Solution

Thanks @Djuro Mandinic for solution:

Dump asset files for dev environment and see if it helps: directions here The downside is that if you change something in asset files you need to dump it again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top