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.
Install older Ruby versions on a M1 MacBook?
In order to make installing of Ruby versions 2.6.x or 2.7.x successful on M1 MacBook using either rbenv
or asdf
(asdf is used in this example) follow these steps:
Upgrade to the latest version of rbenv
or asdf-ruby
plugin using your prefered installation method. In my case it's asdf-ruby
installed over homebrew:
brew upgrade asdf
asdf plugin update ruby
Reinstall the current versions of openssl
, readline
and ruby-build
in order to have the latest versions and configs:brew uninstall --ignore-dependencies readline
brew uninstall --ignore-dependencies openssl
brew uninstall --ignore-dependencies ruby-build
rm -rf /opt/homebrew/etc/openssl@1.1
brew install -s readline
brew install -s openssl
brew install -s ruby-build
In your shell config .bashrc
or .zshrc
add the following ENV variables:export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
export LDFLAGS="-L/opt/homebrew/opt/readline/lib:$LDFLAGS"
export CPPFLAGS="-I/opt/homebrew/opt/readline/include:$CPPFLAGS"
export PKG_CONFIG_PATH="/opt/homebrew/opt/readline/lib/pkgconfig:$PKG_CONFIG_PATH"
export optflags="-Wno-error=implicit-function-declaration"
export LDFLAGS="-L/opt/homebrew/opt/libffi/lib:$LDFLAGS"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include:$CPPFLAGS"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig:$PKG_CONFIG_PATH"
This will ensure that the proper libraries and headers are used during the installations and it will ignore the implicit-function-declaration
that is preventing some versions to continue installation. Note that for some other shells like fish
the exporting of these variables will be a bit different.Now start a new terminal session and you can try installing the older ruby versions:
asdf install ruby 2.7.2
asdf install ruby 2.6.5
Note that really old versions below 2.5 might still have issues. Most of the credits go to this Github issue.UPDATE
For Ruby 2.2 please change the following variable:export RUBY_CONFIGURE_OPTS=openssl@1.0
And do aasdf reshim ruby
Thanks @xjlin0 for this update Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5
Below are the instructions which I have followed to solve this issue:
- Homebrew install:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- watchman install:
brew install watchman
- Install Ruby: followed rbenv Official Github Repo link to install the required version of ruby
- Install CocoaPods:
sudo gem install cocoapods
- CocoaPods in fixed location:
sudo gem install -n /usr/local/bin ffi cocoapods
Upgrading Global Ruby Version on macOS
As per advice from anothermh, uninstalled rbenv and brew versions of Ruby
Uninstallation
brew uninstall ruby
for removing brew version
Use accepted answer on this SO article for removing rbenv
Install Ruby via RVM
Install RVM as per instructions || as per this
rvm install (ruby version)
rvm --default use (ruby version)
can use rvm list
to see available ruby versions.
Related Topics
Include Module in All Minitest Tests Like in Rspec
Get All Products of Category and Child Categories (Rails, Awesome_Nested_Set)
How to Write (Large) Files with Ruby Eventmachine
Regex to Check Alphanumeric String in Ruby
Generate Models from Existing Tables Using Rails 3
Using Rails Form Helpers with Serialized Custom Classes
Persistent Tcp Connection in Rails App
Ruby Symbols Are Not Garbage Collected!? Then, Isn't It Better to Use a String
How to Calculate a String's Width in Ruby
Download a Carrierwave Upload from S3
How to Specify Regexp Options Using Regexp.Union
Remove Adjacent Identical Elements in a Ruby Array
Good Forms Helpers for Sinatra
Rvm Can No Longer Install 1.8.7-P352 on MAC Os X Mountain Lion
I Am Getting This Gem Install Error for Kgio Gem When I Do a Bundle Install