57

Today I installed the curl formula via homebrew, but after installing it (and re-sourcing the shell) i noticed that :

% which curl 
/usr/bin/curl

as a matter of fact, the output of brew install curl stated that it was a keg-only formula, and that since curl was already present in OS X, it didn't link it into Homebrew prefix, as that could cause unspecified problems.

Then it proceeds stating that

Generally there are no consequences of this for you

I would like to know:

  • What sorts of problems exactly?
  • What is the purpose of installing keg-only formulas via Homebrew? How can there be no consequences if the newly installed tool is not in the PATH?
Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
asymmetric
  • 3,800
  • 3
  • 34
  • 52
  • I find the wording of the "Generally there are no consequences of this for you" caveat very confusing, particularly mentioning `LDFLAGS` and `CPPFLAGS`. Took me a while to realize it’s printed for all keg-only formulae. The paragraph breaks don’t make it clear what the message pertains to. – duozmo Jun 24 '15 at 19:31

2 Answers2

60
  • Problems: if a homebrew application is put in the path in front of the default OS X version of the same, really anything might happen. Most common issues are caused by differences between the set of command line options available in the two versions, or differences in the meaning of the options. For curl the consequences might not be so bad, but for other applications you could, at worst, break the OS.
  • Keg-only: now you have two versions of curl! The default OS X, and the homebrew. If you want to use features that are not in the default but in the homebrew, you can do so by calling the homebrew curl explicitly. The precise path depends on how you've got homebrew set up. Because the newly installed version is not in the path, its unlikely to cause a problem unless it is explicitly called.
martin clayton
  • 76,436
  • 32
  • 213
  • 198
  • 6
    Could also run into problems if they're dynamically linked and one's a more recent version - the more recent version's .so might get linked at a higher priority than the older and break the older one's, especially if they're very different versions. – Marc B Jan 14 '11 at 13:26
  • 4
    Git is already installed on Mac OS X 10.8, but The Git Homebrew formula is not keg-only, i.e., it puts `git` "in the path in front of the default OS X version." Is that OK? – ma11hew28 Jul 23 '13 at 15:03
  • 1
    @MattDiPasquale git isn't a critical app, I think it's installed by XCode. Anyway, it wouldn't be a problem for your `system` – Max13 Dec 06 '13 at 12:49
  • Can I add the new curl into the PATH using a different name. Something like `curl-new` instead of `curl`? – CMCDragonkai Jan 16 '14 at 08:02
  • 2
    @CMCDragonkai You could always use a shell alias to do so. http://tldp.org/LDP/abs/html/aliases.html – Jason Crittenden Jan 31 '14 at 21:46
1

I want to add some complement to the second problem(related to the mechanism of keg-only) asked by @asymmetric.

HomeBrew's prefix is /usr/local , and HomeBrew keeps all installed kegs in the default directory, say /usr/local/Cellar. In general, HomeBrew could create symlink for installed formula(non-keg-only formula), and the corresponding symlink is kept in /usr/local/bin. This symlink-creation procedure is automatic when HomeBrew installing the formula. Here the path /usr/local/bin would be called default (symlink) prefix.

On the other hand, according to FAQ of HomeBrew, we have the following guidance:

``keg-only formula is installed only into the Cellar and is not linked into the default prefix. This means most tools will not find it.''

But at the same time the HomeBrew creates symlinks in the directory /usr/local/opt for ALL installed formulae no matter whether they are keg-only or not.

There will be two crucial points we should notice:

  1. By default the default (symlink) prefix /usr/local/bin is in PATH, but the non-prefix /usr/local/opt is NOT in PATH.
  2. By default the default (symlink) prefix /usr/local/bin in general points towards the latest version of formula. So if you want to use the specific version(often in keg-only format) of some formula you could temporarily prepend your PATH with the keg-only formula's bin directory, for example, export PATH="$(brew --prefix)/opt/FormulaName/bin:${PATH}".

The setting of /usr/local/opt mentioned above could resolve the executable-conflict. In general, you might have a formula or program in your system with many different versions, such as the latest version and outdated version, the Apple native version and locally installed version, an so on. It's possible for these situations to cause conflict when you execute or compile some other programs which are somewhat related to the current using formula or program.

GL_n
  • 11
  • 3