15

I'm trying to install Ruby version 2.7.2 on my Mac (latest OS with all updates) and did the following

brew update
brew upgrade rbenv ruby-build

and then

rbenv install 2.7.2
ruby-build: definition not found: 2.7.2

See all available versions with `rbenv install --list'.

If the version you need is missing, try upgrading ruby-build:

  brew update && brew upgrade ruby-build

So I tried following the instructions above and get this

brew update && brew upgrade ruby-build
Already up-to-date.
Warning: ruby-build 20200926 already installed

3 Answers 3

37

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.

5
  • 1
    Wish I could give you more upvotes! Thanks! 💛🍻 Dec 17, 2020 at 1:05
  • 2
    This doesn't work as of 10/2021
    – jdog
    Oct 13, 2021 at 3:07
  • @jdog what exactly doesn't work? What rbevn's version do you use? Oct 19, 2021 at 0:21
  • 1
    this doesn't work for me either :(. On an Apple M1, rbenv installed via brew. rbenv version: 1.2.0.
    – papiro
    Oct 28, 2021 at 4:04
  • for mac (m1 or m2 cheap) you need to add these line too: eval "$(rbenv init -)" export PATH="$HOME/.rbenv/bin:$PATH" which -a ruby
    – MA Deldari
    May 25, 2023 at 2:04
3

The answer from @andrei-kovrov is correct but, alternatively, you can wait until this PR gets merged:

https://github.com/Homebrew/homebrew-core/pull/62096

Btw, this answer will not age well so, for reference, this is where the formulae are staged before they get released:

https://github.com/Homebrew/homebrew-core/pulls

0

It might be an issue reading the correct version of ruby based on the path that is specified. If you already have another version of ruby installed the path might not be updated to look for a newer version.

This article has a lot of really great information on how to set up ruby on a mac: https://stackify.com/install-ruby-on-your-mac-everything-you-need-to-get-going/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.