Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install fails on macOS 15 #182

Open
creativetags opened this issue Oct 2, 2024 · 8 comments
Open

Install fails on macOS 15 #182

creativetags opened this issue Oct 2, 2024 · 8 comments

Comments

@creativetags
Copy link

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
@kaoru
Copy link

kaoru commented Oct 2, 2024

I'm getting the same issue but with less useful error messages.

$ gem install sassc                 
Building native extensions. This could take a while...
ERROR:  Error installing sassc:
	ERROR: Failed to build gem native extension.

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

current directory: /Users/alex/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20241002-3411-surdnl sitelibdir\=./.gem.20241002-3411-surdnl clean

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

make failed, exit code 2

Gem files will remain installed in /Users/alex/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/sassc-2.4.0 for inspection.
Results logged to /Users/alex/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/extensions/arm64-darwin-24/3.3.0/sassc-2.4.0/gem_make.out

@kaoru
Copy link

kaoru commented Oct 2, 2024

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 rubygems/rubygems#1508 (comment) 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

@creativetags
Copy link
Author

So is the solution to rebuild the ruby used by the gemset for the new system version (macOS 15.0 in my case)? Then gems should build ok as they'll use the same compiler right?

@kaoru
Copy link

kaoru commented Oct 3, 2024

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.

@kaoru
Copy link

kaoru commented Oct 4, 2024

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

@mokolabs
Copy link

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)

@elfotografo007
Copy link

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.

@MiladRahmani
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants