0

I can install ruby 2.6 from homebrew and I get ruby 2.6.10. How can I install ruby from Homberw with a fixed version? (Major.Minor.patch)

If I try brew install ruby@2.6.9 or ruby@2.6.10 it is not working. I get this:

Warning: No available formula with the name "ruby@2.6.10". Did you mean ruby@2.6?
==> Searching for similarly named formulae and casks...
==> Formulae
ruby@2.6 ✔

To install ruby@2.6 ✔, run:
  brew install ruby@2.6 ✔

But I want the project to have a fixed ruby version and if that is the case with brew people wouldn't be able to install 2.6.9 anymore or 2.6.10 in the future.

BTW, It must be ruby 2.6 so don't advise upgrading, please.

idan ahal
  • 707
  • 8
  • 21

2 Answers2

1

Homebrew generally uses rolling updates and always installs the newest version of a software. While it has some limited support for versioned formulas, it usually does not support this down to the exact tiny version.

So to answer your specific question about how to install a specific Ruby version with homebrew: you can't.

Instead, to install a specific Ruby version, you should use a Ruby version manager such as rbenv with ruby-build (possibly integrated into asdf), RVM, or chruby with ruby-install. All of these tools allow you to install specific Ruby versions and switch between multiple installed Rubies.

Holger Just
  • 52,918
  • 14
  • 115
  • 123
  • I have tried rbenv. It can't install 2.6.10 on macOS Ventura and also makes a lot of problems with m1 processes. Do you know of another installation manager that can do that with that specification? – idan ahal Jan 23 '23 at 13:36
  • You might want to search Stack Overflow then. There are a lot of previous questions regarding installation of older Ruby versions on M1 with rbenv and other version managers, e.g. https://stackoverflow.com/a/69012677/421705 – Holger Just Jan 23 '23 at 13:45
  • It is not working for me because macOS Venture has updated Xcode build tools. Is there another easy way of doing so without rbenv? – idan ahal Jan 23 '23 at 14:07
0
  1. Enter this command in terminal
eval "$(rbenv init - zsh)"
  1. Install any ruby version with use rbenv - for example rbenv install 2.7.2
  2. Use rbenv global <your need version ruby > - set global ruby version
baim
  • 28
  • 5