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:
- By default the default (symlink) prefix
/usr/local/bin
is in PATH
, but the non-prefix /usr/local/opt
is NOT in PATH
.
- 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.