Skip to content
Latchkey

Ruby sassc Gem Build Fails - Native Compile Error in CI

sassc bundles libsass and compiles it as a native extension. The build fails when there is no C++ compiler - sassc needs g++/clang++, not just a C compiler - or the Ruby headers are missing.

What this error means

bundle install fails with "An error occurred while installing sassc", and the build log shows a C++ compile error or a missing compiler. The long libsass compile starts and then aborts.

gem output
An error occurred while installing sassc (2.4.0), and Bundler cannot continue.

make: g++: No such file or directory
make: *** [Makefile:245: libsass.o] Error 127

Common causes

No C++ compiler on the runner

sassc compiles libsass, which is C++. A C-only toolchain (or none) fails because g++/clang++ is missing.

Missing Ruby headers

The extension also needs the Ruby development headers (ruby-dev) to compile against the interpreter.

How to fix it

Install the C++ toolchain and Ruby headers

Terminal
# Debian/Ubuntu
apt-get update && apt-get install -y build-essential g++ ruby-dev
# Alpine
apk add --no-cache build-base g++ ruby-dev

Consider a maintained alternative

sassc/libsass is deprecated. If you control the dependency, migrating to dartsass-rails or cssbundling avoids the native compile entirely.

How to prevent it

  • Bake g++/build-essential and ruby-dev into images that build sassc.
  • Pin a sassc version known to compile on your toolchain.
  • Prefer a maintained Sass gem that does not compile libsass where feasible.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →