仅桶装自制配方

发布于 2024-10-11 17:22:03 字数 480 浏览 1 评论 0原文

今天我通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

罪歌 2024-10-18 17:22:03
  • 问题:如果将自制应用程序放入其默认 OS X 版本前面的路径中,实际上任何事情都可能发生。最常见的问题是由两个版本中可用的命令行选项集之间的差异或选项含义的差异引起的。对于curl 来说,后果可能不会那么糟糕,但对于其他应用程序来说,最坏的情况可能会破坏操作系统。
  • 仅 Keg:现在你有两个版本的curl!默认的 OS X 和自制程序。如果您想使用自制程序中未包含的默认功能,则可以通过显式调用自制程序curl 来实现。精确的路径取决于您如何设置自制程序。由于新安装的版本不在路径中,因此除非显式调用,否则不太可能导致问题。
  • 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.
浅沫记忆 2024-10-18 17:22:03

我想对@asymmetry提出的第二个问题(与仅桶机制相关)添加一些补充。

HomeBrew 的前缀是 /usr/local ,HomeBrew 将所有已安装的小桶保留在默认目录中,例如 /usr/local/Cellar 。一般来说,HomeBrew 可以为安装的公式(非 keg-only 公式)创建符号链接,相应的符号链接保存在 /usr/local/bin 中。当 HomeBrew 安装公式时,此符号链接创建过程是自动的。这里的路径 /usr/local/bin 将被称为默认(符号链接)前缀。

另一方面,根据 HomeBrew 的常见问题解答,我们有以下指导:

``纯桶配方仅安装到地窖中,不链接到默认前缀。这意味着大多数工具都找不到它。''

但与此同时,HomeBrew 会在目录 /usr/local/opt 中为所有已安装的公式创建符号链接,无论是否它们是否仅限桶。

我们需要注意两个关键点:

  1. 默认情况下,默认(符号链接)前缀 /usr/local/bin 位于 PATH 中,但非前缀 /usr/local/opt 不在 PATH 中。
  2. 默认情况下,默认(符号链接)前缀 /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:

``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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文