Compass file not found error in sass cache

Recently, I was working on a sass project and then started to get strange errors about a file not being found. The error referenced a non-existent file in the sass cache folder. I wasn’t sure why the file was not being generated, I had never seen this before.

The error came in two forms:

Change block raise an execption: No such file or directory @ rb_sysopen - C:/xampp-7.0/htdocs/long-project-name/site/wp-content/themes/long-theme-name/.sass-cache/75fcaf1b4852ceb732871195e41567cc2a7d8997/C%058/xampp-7.0/htdocs/long-project-name/site/wp-content/themes/long-theme-name/sass/variables-site/_variables-site.scssc20170119-11248-10zrts9

Errno::ENOENT on line ["133"] of C: No such file or directory @ rb_sysopen - C:/xampp-7.0/htdocs/long-project-name/site/wp-content/themes/long-theme-name/.sass-cache/75fcaf1b4852ceb732871195e41567cc2a7d8997/C%058/xampp-7.0/htdocs/long-project-name/site/wp-content/themes/long-theme-name/sass/variables-site/_variables-site.scssc20170118-6116-lkkzsz
Run with --trace to see the full backtrace

I ran “cache clean” but it only temporarily fixed the problem, and after saving the error would reappear.

After double checking imports I was convinced that my imports were done correctly, and starting searching online.

It turns out my .sass-cache path was too long, and the file was silently failing and not being outputted to that directory. It never mentioned anywhere that my path was too long, I was trying a suggestion found here:

To fix it,
Add this line to to your config.rb

cache_path = 'C:\temp\sass'

For the record I am using:
compass 1.0.3
ruby 2.3.2

2 thoughts on “Compass file not found error in sass cache

  1. Thank you so much! I just used this and it worked. I’m not using compass anymore but had to fix something on a legacy that required it.

Leave a Reply

Your email address will not be published. Required fields are marked *