I am working on a project that requires ruby 3.0.2 using the x86_64 architecture but I am on an M1 macbook (macos 15.0 Sequoia). I have setup my dev environment with openssl 1.1, readline, libyaml, and gmp from homebrew. When I try to install ruby, I get the following output.
$ arch -x86_64 asdf install ruby 3.0.2
ruby-build: using openssl@1.1 from homebrew
==> Downloading ruby-3.0.2.tar.gz...
-> curl -q -fL -o ruby-3.0.2.tar.gz https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.2.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 19.0M 100 19.0M 0 0 37.1M 0 --:--:-- --:--:-- --:--:-- 37.2M
==> Installing ruby-3.0.2...
WARNING: ruby-3.0.2 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.asdf/installs/ruby/3.0.2" --with-openssl-dir=/opt/homebrew/opt/openssl@1.1 --enable-shared --with-readline-dir=/opt/homebrew/opt/readline --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-ext=openssl,psych,+
-> make -j 10
BUILD FAILED (macOS 15.0 on x86_64 using ruby-build 20240917)
When I check the build log to troubleshoot, I see it full of build errors in bigdecimal.c
, looking like this
bigdecimal.c:249:5: error: 'maybe_unused' attribute cannot be applied to types
249 | ENTER(1);
| ^
bigdecimal.c:68:33: note: expanded from macro 'ENTER'
68 | #define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
| ^
../.././include/ruby/backward/2/attributes.h:168:28: note: expanded from macro 'RB_UNUSED_VAR'
168 | #define RB_UNUSED_VAR(x) x RBIMPL_ATTR_MAYBE_UNUSED()
| ^
../.././include/ruby/internal/attr/maybe_unused.h:31:39: note: expanded from macro 'RBIMPL_ATTR_MAYBE_UNUSED'
31 | # define RBIMPL_ATTR_MAYBE_UNUSED() [[maybe_unused]]
|
I have tried several steps to resolve the issue including updating/reinstalling my command line tools, changing compiler, uninstalling and reinstalling all the used brew packages, installing and updating ruby-build
, and nothing has resolved this issue. Is there a compiler flag that could be used to bypass this error or another step I have missed to resolve this error and get my ruby install working?
I had the same problem on Sequoia 15.0 and was able to install ruby with a few commands found in this thread.
First to solve the bigdecimal.c errors, you can use this patch from nicksieger by running cat ruby-3.0.x.patch | rbenv install --patch 3.0.2
.
In the file bigdecimal.c
, it changes the line:
#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
to
#define ENTER(n) volatile VALUE vStack[n];int iStack=0
Then I had an openssl version issue, in case you run into it as well I solved it with brew link --overwrite openssl@1.1
Cheers!