Ruby: BUILD FAILED (macOS 11.2 using ruby-build 20210119) Mac Big Sur
This is not an official solution. I'm sure the rbenv devs are working on an actual solution but this workaround should help others who are setting up their ruby environments on the new M1 chips for Mac.
Make sure your Terminal is using Rosetta. You can find how to do that using Google.
Uninstall your current
rbenv
following these instructions Removing rbenv. Be sure you also remove all the downloaded versions of ruby if you have any (minus the system default) located in/Users/<your user name>/.rbenv/versions/
.Uninstall the ARM version of Homebrew with:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
Install the x86_64 version of Homebrew with:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
If you run
brew install rbenv
should produce output saying "Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!". This is expected.You want to tell brew to install the older architecture x86_64
arch -x86_64 brew install rbenv
Then finally install the version you want using
arch -x86_64 rbenv install x.x.x
(x = some number i.e. 2.7.2)
From there you just need to remember to tell brew arch -x86_64
when installing other versions of Ruby.
Once an actual fix comes through you'll be able to switch back to the newer architecture and not have to use the arch
argument. You also don't have to do this all the time with brew either, just rbenv.
Ruby installation (2.2.2) fails in macOS Big Sur
EDIT
It looks like OP edited the error in the original message so the below answer is no longer relevant. Leaving it here for posterity.
Updated Answer
Based on discussion in a couple of Github issues on the rbenv repo,
- https://github.com/rbenv/ruby-build/issues/1480
- https://github.com/rbenv/ruby-build/issues/1489
it sounds like Apple changed the default CFLAGS
as part of xcode 12, which makes some of the native extension installations go haywire. It sounds like the solution proposed in those issues is
CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.2
Original answer
The error states it failed due to issues with extensions
The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
so I would suggest trying to install those extensions manually first, then retrying the ruby install.
With brew:
brew install readline
brew install zlib
There are some issues on ruby-build
's github that might help as well:
- https://github.com/rbenv/ruby-build/issues/1076
- https://github.com/rbenv/ruby-build/issues/832#issuecomment-160906530
Related Topics
Jekyll: How to Use Custom Plugins with Github Pages
Do You Know an Alternative Ctags Generator for Ruby
How to Set a Custom User Agent in Ruby
Generate Ssh Keypairs (Private/Public) Without Ssh-Keygen
Ruby Regex- Does Gsub Store What It Matches
How to Enable Tls for Redis 6 on Sidekiq
Add API Key to Every Request in Activeresource
Ruby Split String by Repeating Characters or a Space
How to Establish a Ssl Enabled Tcp/Ip Connection in Ruby
Rspec Testing Redirect to Url with Get Params
Convert Array to Hash While Preserving Array Index Values in Ruby
What Does the Regular Expression [\W-] Mean
How to Test for a Redirect with Rspec and Capybara
How to Generate PDF from Markdown Using Pure Ruby
What Is the Best Diff Library in Ruby
Why Do You Need "Require 'Bundler/Setup'"
What Is the Community-Preferred Ruby Unit Testing Framework
Using Nokogiri HTML Builder to Create Fragment with Multiple Root Nodes