26

I'd like to install several versions of Ruby (or really any Homebrew package) without linking any of them. Basically, I'd like to treat any formula as keg-only.

I can't seem to find a way to do this, although it seems trivial. I thought there'd be something like brew install --no-link <formula>.

Is there a way to do what I want, or some reason why this is a bad idea?

I'd really like to use Homebrew to install Ruby versions, and rbenv to manage them.

also
  • 360

3 Answers3

13

All you have to do is to edit the default formula and customize it for your purpose, which is being keg-only. It is actually very easy to make your own customized version of formulas, and once you edit a formula, Homebrew keeps your personalized version for future uses.

So, just edit the formula file (for the specific tap version you intend to install) and add keg_only "My reason for making this keg-only" within the formula class, for example on a new line directly after the desc command.

In case you haven't edited a formula before, read these few lines from Homebrew's FAQ in order to learn how to do so:

Can I edit formulae myself?

Yes! It’s easy! Just brew edit $FORMULA. You don’t have to submit modifications back to Homebrew/homebrew, just edit the formula as you personally need it and brew install. As a bonus brew update will merge your changes with upstream so you can still keep the formula up-to-date with your personal modifications!

chiborg
  • 362
1

You can run brew install <formula> and then brew unlink <formula>, which removes all the links.

jaimeMF
  • 156
-1

I'm not sure about Ruby, but to do this for many pieces of software, you may want to just download source and adjust the make file, or use the flags for the autoconf configure script to specify the install directory you want, and then you can run it from there.

(From configure --help output)
Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]
Kevin Panko
  • 7,466