sassc-ruby: Saasc 2.4.0 installation error - #include

Hi, when I try to do bundle install this dependency is unable to be installed. How can I solve this issue?

OS: macOS Big Sur v11.5.2 Ruby version: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-darwin20] Rails version: 5.2.6

Installing sassc 2.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/ricardo/.rvm/gems/ruby-2.7.4/gems/sassc-2.4.0/ext
/Users/ricardo/.rvm/rubies/ruby-2.7.4/bin/ruby -I /Users/ricardo/.rvm/rubies/ruby-2.7.4/lib/ruby/2.7.0 -r ./siteconf20210813-15067-5gceb3.rb extconf.rb
creating Makefile

current directory: /Users/ricardo/.rvm/gems/ruby-2.7.4/gems/sassc-2.4.0/ext
make "DESTDIR=" clean

current directory: /Users/ricardo/.rvm/gems/ruby-2.7.4/gems/sassc-2.4.0/ext
make "DESTDIR="
compiling ./libsass/src/ast.cpp
In file included from ./libsass/src/memory.hpp:8,
                 from ./libsass/src/sass.hpp:55,
                 from ./libsass/src/ast.cpp:3:
./libsass/src/memory/allocator.hpp:8:10: fatal error: vector: No such file or directory
    8 | #include <vector>
      |          ^~~~~~~~
compilation terminated.
make: *** [ast.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/ricardo/.rvm/gems/ruby-2.7.4/gems/sassc-2.4.0 for inspection.
Results logged to /Users/ricardo/.rvm/gems/ruby-2.7.4/extensions/x86_64-darwin-20/2.7.0/sassc-2.4.0/gem_make.out

An error occurred while installing sassc (2.4.0), and Bundler cannot continue.
Make sure that `gem install sassc -v '2.4.0' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  bootstrap-email was resolved to 1.0.0.alpha4, which depends on
    sassc

Thanks in advance for the help. Let me know if you need more information.

About this issue

Most upvoted comments

My issue was with how ruby was built when installing it with asdf. Two different versions of ruby had different output for compilers:

# ruby 3.3.3 compiler check
ruby -rrbconfig -e'p RbConfig::CONFIG["CC"]' -e'p RbConfig::CONFIG["CXX"]'
"usr/bin/clang"
"false"
# ruby 3.3.4 compiler check
ruby -rrbconfig -e'p RbConfig::CONFIG["CC"]' -e'p RbConfig::CONFIG["CXX"]'
"clang"
"clang++"

After some searching I came across ruby-build, which is used by asdf-ruby plugin, and ability to specify compiler paths. So I reinstalled ruby:

asdf uninstall ruby 3.3.3
CC="clang" CXX="clang++" asdf install ruby 3.3.3

After that sassc was built properly.

I am not sure how this works with different ruby managers like rvm and rbenv.

Error:

Fetching gem metadata from https://rubygems.org/........
Installing sassc 2.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/briciocardoso/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/sassc-2.4.0/ext
/Users/briciocardoso/.rbenv/versions/3.3.5/bin/ruby extconf.rb
creating Makefile

current directory: /Users/briciocardoso/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20250109-40459-qzp70v sitelibdir\=./.gem.20250109-40459-qzp70v clean

current directory: /Users/briciocardoso/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20250109-40459-qzp70v sitelibdir\=./.gem.20250109-40459-qzp70v
compiling ./libsass/src/ast.cpp
make: *** [ast.o] Error 1

make failed, exit code 2

....

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

In Gemfile:
  sass-rails was resolved to 6.0.0, which depends on
    sassc-rails was resolved to 2.1.2, which depends on
      sassc

That worked for me:

rm -rf /Library/Developer/CommandLineTools/
xcode-select --install
rbenv uninstall 3.3.5
CC="clang" CXX="clang++" rbenv install 3.3.5
bundle install

@AJ-Ayush I resolved this by deleting the directory /Library/Developer/CommandLineTools/ on my iMac. After that, It automatically installs the new dev tool and then run bundle install

@AJ-Ayush I resolved this by deleting the directory /Library/Developer/CommandLineTools/ on my iMac. After that, It automatically installs the new dev tool and then run bundle install

This fixed for me.

Though I did:

  • rm -rf /Library/Developer/CommandLineTools/
  • xcode-select --install
  • rbenv install 3.3.4
  • bundle install

I had the following situation

# ruby v3.2.5 compiler check
ruby -rrbconfig -e'p RbConfig::CONFIG["CC"]' -e'p RbConfig::CONFIG["CXX"]'
"clang"
"false"

This fix but without asdf worked for me

rbenv uninstall 3.2.5
CC="clang" CXX="clang++" rbenv install 3.2.5

I’m using mise. I am trying this:

CC="clang" CXX="clang++" mise install ruby 3.4.2

But installing sassc after (and eventmachine) still both fail. sassc fails the same way than described above: https://github.com/sass/sassc-ruby/issues/225#issuecomment-2580196962

How can I verify if the environment variables in my command were passed through the build correctly?

Edit: Never mind. I found a way, but passing env vars seems to have no effect with mise:

❯ ruby -e 'puts RbConfig::CONFIG["CC"]; puts RbConfig::CONFIG["CXX"]'
clang
false

Edit 2: Even with ruby-build, it doesn’t work:

❯ export CC=clang CXX=clang++
❯ ruby-build 3.4.2 ~/3.4.2
❯ cd ~/3.4.2
❯ cd bin
❯ ./ruby -e 'puts RbConfig::CONFIG["CC"]; puts RbConfig::CONFIG["CXX"]'
clang
false

How come setting CXX works for the rest of you? 🤨

Edit 3: Well, huh. Found this bug filed just 15 days ago. It’s about ruby-build quietly setting CXX to false when something fails. Found out I also had to wipe my command-line tools:

❯ rm -rf /Library/Developer/CommandLineTools/
❯ xcode-select --install
❯ export CC=clang CXX=clang++
❯ ruby-build 3.4.2 ~/3.4.2
❯ cd ~/3.4.2/bin
❯ ./ruby -rrbconfig -e'p RbConfig::CONFIG["CC"]' -e'p RbConfig::CONFIG["CXX"]'
"clang"
"clang++ -std=gnu++11”

That also fixed the issue I was having with mise:

❯ mise install ruby
❯ ./ruby -rrbconfig -e'p RbConfig::CONFIG["CC"]' -e'p RbConfig::CONFIG["CXX"]'
"clang"
"clang++ -std=gnu++11”
❯ gem install sassc # Worked!

Sorry for updating my comments several times—didn’t want to notify everyone with a series of comments. I hope this helps someone stuck with the same problem using mise.

@crnastena Do you know what the equivalent would be for rvm ? I am running into the same issue

@shellandbull rvm seems to provide the --with-gcc option. maybe you can give it a try. https://github.com/rvm/rvm/blob/e732b5a46aaab81fb0988c6292d526385d62052b/scripts/functions/build#L20

I got the same error with:

  • rails 7.1.4
  • sass-rails (6.0.0)
  • ruby 3.1.2
  • MacOS Sequoia (Version 15.0)
  • libsass and gcc already installed via brew
Fetching gem metadata from https://rubygems.org/.........
Installing sassc 2.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/thaidang/.rvm/gems/ruby-3.1.2@sia/gems/sassc-2.4.0/ext
/Users/thaidang/.rvm/rubies/ruby-3.1.2/bin/ruby extconf.rb
creating Makefile

current directory: /Users/thaidang/.rvm/gems/ruby-3.1.2@sia/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20240927-12423-ir9f8b sitelibdir\=./.gem.20240927-12423-ir9f8b clean

current directory: /Users/thaidang/.rvm/gems/ruby-3.1.2@sia/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20240927-12423-ir9f8b sitelibdir\=./.gem.20240927-12423-ir9f8b
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

Gem files will remain installed in /Users/thaidang/.rvm/gems/ruby-3.1.2@sia/gems/sassc-2.4.0 for inspection.
Results logged to /Users/thaidang/.rvm/gems/ruby-3.1.2@sia/extensions/arm64-darwin-23/3.1.0/sassc-2.4.0/gem_make.out

Alright, it was pretty easy to solve. If someone stumbles upon this, just run sudo apt install g++ and you’re good to go. My error was a bit different from OP’s though, a permission error.

@crnastena Do you know what the equivalent would be for rvm ? I am running into the same issue

@shellandbull RVM seems to provide the --with-gcc option. maybe you can give it a try. https://github.com/rvm/rvm/blob/e732b5a46aaab81fb0988c6292d526385d62052b/scripts/functions/build#L20

Thank you! if you’re using rvm: rvm reinstall 3.X.X --with-gcc

asdf uninstall ruby 3.3.3
CC="clang" CXX="clang++" asdf install ruby 3.3.3

After that sassc was built properly.

I am not sure how this works with different ruby managers like rvm and rbenv.

This also works for me, thanks 🙏🏾. And installation via rbenv is as same as asdf (rbenv uses ruby-build to install specific version ruby too).

I’m not familiar with the Mac ecosystem, but the error is definitely related to their specific compiler. Maybe they need some special build flags or the compiler version is simply outdated. Try to use a different one if possible.