cannot load such file -- sassc

Updated: 

Rails Mastery course troubleshooting: Learn how to resolve the 'cannot load such file -- sassc' error and continue your journey to becoming a full-stack developer.

This lesson is from Full Stack Rails Mastery.

Buy Now
Sometimes, you may still run into this error when you start the Rails server in development or run assets:precompile (while deploying to a server, for instance):

cannot load such file -- sassc

/tmp/build/vendor/bundle/ruby/3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require'
/tmp/build/vendor/bundle/ruby/3.1.2/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:35:in `require'
/tmp/build/vendor/bundle/ruby/3.1.2/gems/sprockets-4.1.1/lib/sprockets/autoload/sassc.rb:2:in `<main>'
...


And you think, "but I'm not even using SASS! # £$^%" It can be a real headscratcher.

Why it happens


It's most probably a local caching issue.

If you tried out one of the SASS gems in your app and later removed it or switched to a branch which does not have SASS at all, you may still run into this error because some files got cached locally.

How to fix it


Clear the temporary cache by running this on the command line in your app's root directory:
rails tmp:cache:clear