Search code examples
rubyrvmmacos-monterey

How to install Ruby 3.1.0 on MacOS Monterey


I am trying to install Ruby 3.1.0 using RVM on MacOS Monterey, v12.0.1, but it's returning an error while compiling.

I tried updating Homebrew, and uninstalling and reinstalling everything but I am getting the same error.

This is the error in the terminal window:

ruby-3.1.0 - #removing src/ruby-3.1.0 - please wait
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/12.0/x86_64/ruby-3.1.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/sindhuja.n/.rvm/rubies/ruby-3.1.0, this may take a while depending on your cpu(s)...
ruby-3.1.0 - #downloading ruby-3.1.0, this may take a while depending on your connection...
ruby-3.1.0 - #extracting ruby-3.1.0 to /Users/sindhuja.n/.rvm/src/ruby-3.1.0 - please wait
ruby-3.1.0 - #configuring - please wait
ruby-3.1.0 - #post-configuration - please wait
ruby-3.1.0 - #compiling - please wait
Error running '__rvm_make -j12',
please read /Users/sindhuja.n/.rvm/log/1643979372_ruby-3.1.0/make.log

There has been an error while running make. Halting the installation.

This is the error log file:

building .ext/include/x86_64-darwin21/rb_mjit_min_header-3.1.0.h
make[1]: Nothing to be done for `srcs'.
generating transdb.h
transdb.h updated
linking shared-library libruby.3.1.dylib
error in initial header file:
In file included from /var/folders/ky/347m_s3x7d15w435j_pvl2cc0000gn/T/20220204-43863-1rn0v3.c:1:
/var/folders/ky/347m_s3x7d15w435j_pvl2cc0000gn/T/20220204-43863-34xdve.h:7176:66: fatal error: expected identifier or '('
pthread_override_qos_class_end_np(pthread_override_t __override);#pragma clang assume_nonnull end
                                                                 ^
1 error generated.
make: *** [.ext/include/x86_64-darwin21/rb_mjit_min_header-3.1.0.h] Error 1
make: *** Waiting for unfinished jobs....
+__rvm_make:0> return

Solution

  • I had the same error for rbenv 3.1.0 with Monterey12.3beta & Xcode13.3beta. but once I switched to Xcode13.0, the error's gone.

    I guess the error's due to or related to clang version..