sass/sassc-rails

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

alaarab opened this issue · 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.

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.

@alaarab @bjgaynor were you able to fix this?

Uysim commented

Did anyone manage to resolve this?

Did anyone manage to resolve this? UP!

@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.

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.

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: #122

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.