sassc-rails icon indicating copy to clipboard operation
sassc-rails copied to clipboard

sassc syntax error on RAILS_ENV=production bundle exec rake assets:precompile due to a specific line in my CSS

Open alaarab opened this issue 6 years ago • 9 comments

After attempting RAILS_ENV=production bundle exec rake assets:precompile, i get the following error

SassC::SyntaxError: Error: Invalid CSS after "...ia screen\\0 and": expected "{", was "(max-width: 1024px)"
        on line 18866 of stdin
>> @media screen\0 and (max-width: 1024px) {

It looks like this has to do with screen\0..? Not sure exactly why, but it seems like only sassc compiler is noticing this as invalid, however, it came straight from a reputable bootstrap theme, and has always worked before dropping in sassc-rails.

alaarab avatar Aug 09 '19 01:08 alaarab

It's taking issue with all of my CSS too, seems like the files aren't loading in the right order or something. Incredibly frustrating to see it throw me syntax errors with valid, working CSS.

bjgaynor avatar Oct 09 '19 22:10 bjgaynor

@alaarab @bjgaynor were you able to fix this?

pandurang90 avatar Oct 22 '19 12:10 pandurang90

Did anyone manage to resolve this?

Uysim avatar Mar 27 '20 09:03 Uysim

Did anyone manage to resolve this? UP!

delacruzjames avatar Dec 08 '20 04:12 delacruzjames

@delacruzjames I do remember running into this issue when I was upgrading my rails app, but I don't remember what my solution was. I did not change my CSS at all, since the CSS belonged to a theme and I didn't want to do that. Looking back at my app, I see I commented out this gem completely from my Gemfile, and have gem "sass-rails", ">= 6" in my Gemfile, which is essentially currently supposed to just be a wrapper for this Gem, so I'm not sure what made this start working for me. It might have been some other change I made that truly resolved this.

alaarab avatar Dec 16 '20 20:12 alaarab

I already figured it out the issue. in rails 6 you have to pack everything in javacscript/packs/application.js so when you run rake assets:precompile there is no problem.

delacruzjames avatar Dec 17 '20 04:12 delacruzjames

I am getting a similar error as well:

** Execute assets:precompile
rake aborted!
SassC::SyntaxError: Error: 1.75rem/add isn't a valid CSS value.
        on line 2746 of stdin
>> e%3c/svg%3e") #fff no-repeat center right 1.75rem/add(0.75em, 0.375rem) add(
   ------------------------------------------^
stdin:2746

Having a very hard time trying to figure out what's causing this.

EDIT: Ok so for me, it was a really dumb inclusion of scss files in the wrong order, but even when I fixed that I was getting segmentation errors while precompiling. This issue helped me: https://github.com/sass/sassc-rails/issues/122

Tashows avatar Dec 17 '20 08:12 Tashows

This answer on SO helped me: https://stackoverflow.com/questions/70401077/rails-7-asset-pipeline-sasscsyntaxerror-with-tailwind/70665740#70665740

I put inside production.rb and deployment to Heroku was fine. However I've the gem "sassc-rails" commented out in my Gemfile though.

wongwf82 avatar Nov 14 '22 06:11 wongwf82