Ruby 2.2.1 is failing on install on mac
The offending error in the full log seems to be
encoding.c:825:2: error: implicit declaration of function 'rb_str_change_terminator_length' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
rb_str_change_terminator_length(obj, oldtermlen, termlen);
which seems similar to what was discussed in https://github.com/rbenv/ruby-build/discussions/1854 and https://github.com/rbenv/ruby-build/issues/1489 .In that case, this might help:
CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.1
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)
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.
Related Topics
Browsing Ruby Code a La Smalltalk
Ruby/Rails 3.1: Given a Url String, Remove Path
How to Host Gem in Github and Use It
Hw Impossibility: "Create a Rock Paper Scissors Program in Ruby Without Using Conditionals"
Crontab Not Running Ruby Script
How to Deploy a Threadsafe Asynchronous Rails App
Gem Install Rmagick Fails on Os X El Capitan
Filtering a List Using Checkboxes
Gem Ransack Doesn't Return Any Results When Searched with Full Name
Skipping: Touch Associations When Saving an Activerecord Object
Is The Assignment Operator Really "Just" an Operator
How to Get Content from a Website Using Ruby/Rails
Error Installing Ruby in Yosemite
Rails Validating Search Params
Can You Specify The Http Method to Use with Sinatra's Redirect
Cucumber Embed for Screenshots Not Linking to Screenshot