Error installing ruby 2.6.7 on mac os - how to resolve?
Yes, this is a known issue upstream: https://bugs.ruby-lang.org/issues/17777
ruby-build is also tracking this issue: https://github.com/rbenv/ruby-build/issues/1489
The work around is to run the following code, and install ruby 2.6.7 again:
$ export warnflags=-Wno-error=implicit-function-declaration
$ rbenv install 2.6.7
-or-
$ CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.6.7
Looks like this can also impact gem installation with native extensions (mysql2
is one of those):
gem install <GEMNAME> -- --with-cflags="-Wno-error=implicit-function-declaration"
Need help installing Ruby 2.7.2 on Mac
You need to install the latest ruby-build
$ brew unlink ruby-build # remove STABLE version
$ brew install --HEAD ruby-build
$ rbenv install -l | grep '2.7.2'
2.7.2
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all' to show all local versions.
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.
Related Topics
Expected #Count to Have Changed by 1, But Was Not Given a Block
Run a Command Line with Custom Environment
Convert Array-Of-Hashes to a Hash-Of-Hashes, Indexed by an Attribute of the Hashes
How to Convert Utf8 Combined Characters into Single Utf8 Characters in Ruby
What Are the Steps Needed to Create and Publish a Rubygem of Your Own
How to Put a Delay on a Loop in Ruby
The Program 'Rails' Can Be Found in the Following Packages - Issue with Some App and Rvm
Is There a Method to Limit/Clamp a Number
Making a Module Inherit from Another Module in Ruby
How to Specify a Read Timeout for a Net::Http::Post.New Request in Ruby 2
Documentation for Psych To_Yaml Options
Multiple Level Nesting in Yaml
Suppresing Output to Console with Ruby
Rails - Aciverecord Use :Dependent => :Destroy on Condition
Rails Initializes Extremely Slow on Ruby 1.9.1
How to Fix a Slow Implicit Query on Pg_Attribute Table in Rails
What's the Difference Between /\P{Alpha}/I and /\P{L}/I in Ruby