仅桶装自制配方
今天我通过 homebrew
安装了 curl
公式,但是在安装它(并重新采购 shell)后我注意到:
% which curl
/usr/bin/curl
事实上,的输出>brew install curl
声明它是一个仅桶公式,并且由于 curl
已经存在于 OS X 中,因此它没有将其链接到Homebrew 前缀,因为这可能会导致未指定的问题。
然后它继续指出
一般来说,这不会对您造成任何后果
我想知道:
- 到底是什么类型的问题?
- 通过 Homebrew 安装仅桶配方的目的是什么?新安装的工具不在
PATH
中怎么可能没有后果呢?
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
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想对@asymmetry提出的第二个问题(与仅桶机制相关)添加一些补充。
HomeBrew 的前缀是
/usr/local
,HomeBrew 将所有已安装的小桶保留在默认目录中,例如/usr/local/Cellar
。一般来说,HomeBrew 可以为安装的公式(非 keg-only 公式)创建符号链接,相应的符号链接保存在/usr/local/bin
中。当 HomeBrew 安装公式时,此符号链接创建过程是自动的。这里的路径/usr/local/bin
将被称为默认(符号链接)前缀。另一方面,根据 HomeBrew 的常见问题解答,我们有以下指导:
但与此同时,HomeBrew 会在目录
/usr/local/opt
中为所有已安装的公式创建符号链接,无论是否它们是否仅限桶。我们需要注意两个关键点:
/usr/local/bin
位于PATH
中,但非前缀/usr/local/opt
不在PATH
中。/usr/local/bin
通常指向最新版本的公式。因此,如果您想使用某些公式的特定版本(通常为仅桶格式),您可以临时在您的PATH
前面添加仅桶公式的bin
目录,例如例如,导出 PATH="$(brew --prefix)/opt/FormulaName/bin:${PATH}"
。上述
/usr/local/opt
的设置可以解决可执行文件冲突。一般来说,您的系统中可能有一个公式或程序有许多不同的版本,例如最新版本和过时版本、Apple本机版本和本地安装版本等等。当您执行或编译一些与当前使用的公式或程序有一定关系的其他程序时,这些情况可能会引起冲突。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:
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:
/usr/local/bin
is inPATH
, but the non-prefix/usr/local/opt
is NOT inPATH
./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 yourPATH
with the keg-only formula'sbin
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.