SASS does not compile in symfony

I am trying to use SASS with an Assetic bundle with symfony. I followed the basic tutorial here . However, it doesn't generate any css files. I've tried using different outputs, checking file permissions and communicating with filters, but I'm not really sure where to go from here.

Relevant config.yml code:

# Assetic Configuration    
assetic:
    debug:          '%kernel.debug%'
    use_controller: '%kernel.debug%'
    filters:
        cssrewrite: ~
        scssphp: 
          bin: /usr/local/lib/ruby/gems/2.3.0/gems/sass-3.4.24
          apply_to: .scss$

      

And this is my stylesheet.html.twig which I include in my base.html.twig

{% stylesheets 
    'sass/style.scss' 
    filter = "scssphp" output='css/sass.css' %}
    <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

      

I tried using the following command line:

php bin/console assetic:dump --env=prod --no-debug

      

And got the following error:

[Assetic\Exception\FilterException]                                          
  An error occurred while running:                                             
  '/usr/local/lib/ruby' '/usr/local/lib/ruby/gems/2.3.0/gems/sass-3.4.24' '--  
  load-path' '/Applications/XAMPP/xamppfiles/htdocs/my_website/app/../web/sas  
  s' '--scss' '--load-path' '/Applications/XAMPP/xamppfiles/htdocs/my_website  
  /app/../web' '--cache-location' '/Applications/XAMPP/xamppfiles/htdocs/my_w  
  ebsite/var/cache/prod' '/private/var/folders/_2/xkw80vl13zj0xw0nm7j8c4bc000  
  0gn/T/assetic_sassqn8iBF'                                                    
  Error Output:                                                                
  sh: /usr/local/lib/ruby: is a directory                                      
  sh: line 0: exec: /usr/local/lib/ruby: cannot execute: Undefined error: 0    
  Input:
  [...]

      

The rest of the error was just my scss file. I'm not really sure what the error is telling me.

Thank:)

+3


source to share


1 answer


I think you need to find the correct path to ruby

(this error means it is /usr/local/lib/ruby

not your ruby โ€‹โ€‹interpreter, but just a folder) and sass

.

  • Execute which ruby

    . It will print the path to the ruby. For me it is /usr/bin/ruby

    .
  • Set up the correct path in your config:
    assetic:
        debug: '% kernel.debug%'
        use_controller: '% kernel.debug%'
        ruby: / usr / bin / ruby
        filters:
            cssrewrite: ~
            scssphp: 
            bin: /usr/local/lib/ruby/gems/2.3.0/gems/sass-3.4.24        
            apply_to: .scss $
  1. If it still doesn't work, you may need to find the right path as well sass

    . I am looking for it in the following folders:

    find / usr / local / bin / | grep sass find / usr / bin / | grep sass find / usr / lib / | grep sass

The first command gave me this output:



/usr/local/bin/sass-convert
/usr/local/bin/node-sass
/usr/local/bin/sass

      

The last line shows the path. Try to change it in your config, for example:

assetic:
    debug:          '%kernel.debug%'
    use_controller: '%kernel.debug%'
    ruby: /usr/bin/ruby
    filters:
        cssrewrite: ~
        scssphp: 
          bin: /usr/local/bin/sass
          apply_to: .scss$

      

Let me know if it works.

0


source







All Articles