Installing sassc 2.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/mark/.rvm/gems/ruby-3.3.4@abc/gems/sassc-2.4.0/ext
/Users/mark/.rvm/rubies/ruby-3.3.4/bin/ruby extconf.rb
creating Makefile
current directory: /Users/mark/.rvm/gems/ruby-3.3.4@abc/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20241002-52885-enwabf sitelibdir\=./.gem.20241002-52885-enwabf clean
current directory: /Users/mark/.rvm/gems/ruby-3.3.4@abc/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20241002-52885-enwabf sitelibdir\=./.gem.20241002-52885-enwabf
compiling ./libsass/src/ast.cpp
In file included from ./libsass/src/ast.cpp:3:
In file included from ./libsass/src/sass.hpp:55:
In file included from ./libsass/src/memory.hpp:8:
./libsass/src/memory/allocator.hpp:8:10: fatal error: 'vector' file not found
8 | #include <vector>
| ^~~~~~~~
1 error generated.
make: *** [ast.o] Error 1
make failed, exit code 2
In case this is useful to someone, most of the above didn’t work for me, but this did:
brew install llvmEdit
~/.rbenv/versions/3.3.6/lib/ruby/3.3.0/arm64-darwin24/rbconfig.rbto say:It looks like a new version of “Command Line Tools for Xcode” just released and might have fixed this 🤞
On Apple Silicon MBPro
I use
miseso I edited~/.local/share/mise/installs/ruby/3.3.6/lib/ruby/3.3.0/arm64-darwin24/rbconfig.rbchangedCONFIG["CXX"] = "false"toCONFIG["CXX"] = "clang++"gem install sassc -v '2.4.0' --source 'https://rubygems.org/'worked after those changesFor me this worked
thanks to @elfotografo007 , @phantaszm and @Tomcat-Engineering
this i got from this comment https://github.com/sass/sassc-ruby/issues/225#issuecomment-2580196962
and then in the file
I changed the line
per
for this one thanks to @Tomcat-Engineering
For me rebuilding Ruby was the cause of the problem rather than the solution 😅
My timeline went something like this:
rbenv install 3.3.5on macOS 14.7 - everything was finerm -rf ~/.rbenv/versions/3.3.5 && rbenv install 3.3.5-gem install sasscno longer worked!~/.rbenv/versions/3.3.5/./lib/ruby/3.3.0/arm64-darwin24/rbconfig.rbsaid CXX=falserbconfig.rbto say CXX=“clang++”gem install sasscworkedI’m sure there’s a better way to do steps 3-5 there, or a bug in rbenv/ruby-build/ruby itself somewhere that will be fixed and make step 3 not result in a broken situation.
To be clear, I don’t think this is a sassc bug, it’s just happened for sassc because it’s the only C++ native extensions gem I’m using.
I managed to get it to build by changing the Makefile from
CXX = falsetoCXX = clang++.I don’t know why
extconf.rb/mkmfis creating a Makefile where CXX is set to ‘false’. I assume it doesn’t do that on macOS 14.x, but I don’t have access to an older Macbook to test on right now.Based on https://github.com/rubygems/rubygems/issues/1508#issuecomment-188899250 it looks like it comes from
RbConfig::CONFIG["CXX"]?I was able to edit my
/Users/alex/.rbenv/versions/3.3.5/./lib/ruby/3.3.0/arm64-darwin24/rbconfig.rbfile to set CXX to “clang++” and then successfully build sassc 2.4.0 usingbundle install.Thank you, @kaoru. This saved my day 😃
In my case, it was fixed by updating the
CONFIG["CXX"]in~/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/x86_64-darwin24/rbconfig.rb.It worked for me after installing llvm and updating
rbconfig.rbto sayCXX="clang++":Mine is an Intel Mac running Sequoia 15.1. If you are running Apple Silicon, you will need to change the path to whatever
brew --prefix llvmoutputs.Thanks all for sharing information. I was able to get it to work via:
sassc)$ xcode-select --versionfor me reportsxcode-select version 2409)gem install sasscshould workThough I’m also seeing that manually editing the rbconfig file might also work. As a shortcut others can use
findto locate this file$ find "/Users/$(whoami)/.rubies" -name rbconfig.rbif they are using chruby and ruby-install. I wrote up more details of my adventure here https://www.schneems.com/2025/03/17/installing-the-sassc-ruby-gem-on-a-mac-a-debugging-story/.I’m curious about what this is. I.e. what was the root of the problem? How does Ruby detect CXX? What did the command line tools do to that fixed the issue? I searched CXX in ruby/ruby https://github.com/search?q=repo%3Aruby%2Fruby CXX&type=code didn’t find anything that stood out. I’m not terribly familiar with what happens in Ruby during the compilation pipeline. I found some things that look promising searching for
clang++https://github.com/search?q=repo%3Aruby%2Fruby+clang%2B%2B&type=code.For me (Sequoia 15.2, Ruby 3.3.6, MacBook Air M1) also installing
llvmand editing therbconfig.rbsolved the issue, however, I’m not 100% sure why I need to make these changes so if someone could explain it, I’d highly appreciate it.FWIW… none of these fixes worked for me.
(I’m running macOS 15.0.1 on a M1 Studio Ultra, with Xcode command line tools 16.0)
I was able to get this working by force removing Xcode Command Line Tools, reinstalling them, reinstalling Ruby, and then installing
sassc.this worked for my m1 mac on Sonoma 14.7.3 on ruby 3.3.6 while using RVM. Just be sure to modify the file path to the appropriate
rbconfig.rbI havearm64-darwin23, thanks @alvarobyrneI ran into this problem and the solution from @Tomcat-Engineering worked for me. Much thanks.
None of them worked for me, (macOs Sequoia Version 15.1.1 (24B91) - Apple M2 Pro) please let me know if you have any idea.