Search code examples
ruby-on-railssassassetsprecompile

Sass incoherent indentation during assets precompilation


I am trying to run rake assets:precompile before my deployment and I keep havig this error :

rake aborted!
Sass::SyntaxError: Inconsistent indentation: 1 tab was used for indentation, but the rest of the document was indented using 1 space.
  (in /home/me/workspace/myapp/app/assets/stylesheets/application.sass)
(sass):16

I've tried to turn tabs into spaces with expand --tabs=2 app/assets/stylesheets/application.sass but it's inneffective.

I've also tried to delete line 16 from app/assets/stylesheets/application.sass but the trace was still exactly the same so the (sass):16 line may refer to an error id.

I did expand --tabs=2 with all of my stylesheets but nothing changed.

EDIT

To change tabs into spaces quickly, I recommand using vim and typing this :

:set tabstop=2 shiftwidth=2 expandtab
:retab
:wq

Or adding the first line to your .vimrc and then just typing the 2 final lines.


Solution

  • Pesky error - tabs and spaces are actually different characters

    The bottom line is that you'll have a tab somewhere, whereas you'll be using a single space in the other stylesheets of your application.

    --

    Debug

    Personally, I'll be looking at removing every "dependency" from your application.css.sass file, and then slowly adding them one-by-one again. This will give you the most informed idea on where the issue will reside (if I were a betting man, I'd say it would be in one of your dependent files!)

    As with most software bug fixes, the solution will be to cut it down to the bare essentials, and then build it up piece-by-piece again