sassc-rails: Install fails on macOS 15

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

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 4
  • Comments: 25 (2 by maintainers)

Most upvoted comments

In case this is useful to someone, most of the above didn’t work for me, but this did:

  1. brew install llvm

  2. Edit ~/.rbenv/versions/3.3.6/lib/ruby/3.3.0/arm64-darwin24/rbconfig.rb to say:

    CONFIG["CXX"] = "/opt/homebrew/opt/llvm/bin/clang++"
    

It looks like a new version of “Command Line Tools for Xcode” just released and might have fixed this 🤞

$ softwareupdate --history | grep "Command Line Tools for Xcode" | tail -n 1
Command Line Tools for Xcode                       16.0       03/10/2024, 19:44:52  

$ rbenv install 3.3.5

$ ruby -rrbconfig -e'p RbConfig::CONFIG.slice("CC", "CXX")' 
{"CC"=>"clang", "CXX"=>"clang++"}

$ gem install sassc
Building native extensions. This could take a while...
Successfully installed sassc-2.4.0
Parsing documentation for sassc-2.4.0
Installing ri documentation for sassc-2.4.0
Done installing documentation for sassc after 1 seconds
1 gem installed

On Apple Silicon MBPro

# OS
ProductName:       macOS
ProductVersion:    15.1.1
BuildVersion:      24B91

# Ruby
Version:     3.3.6
brew install llvm

export  PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

I use mise so I edited ~/.local/share/mise/installs/ruby/3.3.6/lib/ruby/3.3.0/arm64-darwin24/rbconfig.rb changed CONFIG["CXX"] = "false" to CONFIG["CXX"] = "clang++"

gem install sassc -v '2.4.0' --source 'https://rubygems.org/' worked after those changes

# OS
ProductName:		macOS
ProductVersion:		15.2
BuildVersion:		24C101

# Architecture
arm64
Apple M2

# Ruby
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin24]
arm64-darwin24

# ruby version manager
rvm 1.29.12 

For me this worked

brew install llvm

thanks to @elfotografo007 , @phantaszm and @Tomcat-Engineering

CC="clang" CXX="clang++" rvm install 3.3.6 

this i got from this comment https://github.com/sass/sassc-ruby/issues/225#issuecomment-2580196962

and then in the file

.rvm/rubies/ruby-3.3.6/lib/ruby/3.3.0/arm64-darwin24/rbconfig.rb

I changed the line

  CONFIG["CXX"] = "false"

per

  CONFIG["CXX"] = "/opt/homebrew/opt/llvm/bin/clang++"

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:

  1. rbenv install 3.3.5 on macOS 14.7 - everything was fine
  2. Upgraded to macOS 15.0 - everything was fine
  3. rm -rf ~/.rbenv/versions/3.3.5 && rbenv install 3.3.5 - gem install sassc no longer worked!
  4. ~/.rbenv/versions/3.3.5/./lib/ruby/3.3.0/arm64-darwin24/rbconfig.rb said CXX=false
  5. Updated rbconfig.rb to say CXX=“clang++”
  6. gem install sassc worked

I’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 = false to CXX = clang++.

$ vim Makefile # CXX = clang++

$ make
compiling ./libsass/src/ast.cpp
compiling ./libsass/src/ast2c.cpp
compiling ./libsass/src/ast_fwd_decl.cpp
compiling ./libsass/src/ast_sel_cmp.cpp
...
compiling ./libsass/src/json.cpp
./libsass/src/json.cpp:1289:3: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
  sprintf(buf, "%.16g", num);
  ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:274:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/sys/cdefs.h:218:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
1 warning generated.
...
compiling ./libsass/src/util_string.cpp
compiling ./libsass/src/values.cpp
linking shared-object sassc/libsass.bundle

I don’t know why extconf.rb/mkmf is 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.rb file to set CXX to “clang++” and then successfully build sassc 2.4.0 using bundle install.

$ bundle
Fetching gem metadata from https://rubygems.org/........
Installing sassc 2.4.0 with native extensions
Fetching sassc-rails 2.1.2
Installing sassc-rails 2.1.2
Fetching sass-rails 6.0.0
Installing sass-rails 6.0.0
Bundle complete! 152 Gemfile dependencies, 322 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
3 installed gems you directly depend on are looking for funding.
  Run `bundle fund` for details

Thank you, @kaoru. This saved my day 😃

OS: macOS Sequoia Version 15.1.1 (24B91)
ruby: 3.1.0
sassc:  2.4.0

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.rb to say CXX="clang++":

brew install llvm
export PATH="/usr/local/opt/llvm/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"

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 llvm outputs.

Thanks all for sharing information. I was able to get it to work via:

  • Uninstall(ing) your ruby version(s)
  • Delete your gems (or at least sassc)
  • Update to a recent Xcode release ($ xcode-select --version for me reports xcode-select version 2409)
  • Re-compile Ruby version(s)
  • Now gem install sassc should work

Though I’m also seeing that manually editing the rbconfig file might also work. As a shortcut others can use find to locate this file $ find "/Users/$(whoami)/.rubies" -name rbconfig.rb if 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/.

It looks like a new version of “Command Line Tools for Xcode” just released and might have fixed this 🤞

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 llvm and editing the rbconfig.rb solved 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.

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
# remove and then compile/install Ruby here...
gem install sassc

OS

ProductName: macOS ProductVersion: 15.2 BuildVersion: 24C101

Architecture

arm64 Apple M2

Ruby

ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin24] arm64-darwin24

ruby version manager

rvm 1.29.12 For me this worked

brew install llvm thanks to @elfotografo007 , @phantaszm and @Tomcat-Engineering

CC=“clang” CXX=“clang++” rvm install 3.3.6 this i got from this comment sass/sassc-ruby#225 (comment)

and then in the file

.rvm/rubies/ruby-3.3.6/lib/ruby/3.3.0/arm64-darwin24/rbconfig.rb I changed the line

CONFIG[“CXX”] = “false” per

CONFIG[“CXX”] = “/opt/homebrew/opt/llvm/bin/clang++” for this one thanks to @Tomcat-Engineering

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.rb I have arm64-darwin23, thanks @alvarobyrne

I 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.