Macports:-f 标志到底是什么意思?

Macports: what exactly does the -f flag mean?

对比一下

sudo port install [port_name]

sudo port -f install [port_name]

标志 -f 在这种情况下究竟做了什么?为什么我们不在每次安装新端口时都使用 -f 标志?

标志-f是强制install/install。如果存在阻止 macports installing/uninstalling 的依赖项,您可以使用 -f 标志强制 install/uninstall 但这不是 installing/uninstalling.

的理想方式

看看https://guide.macports.org/

的解释
sudo port uninstall libcomerr
--->  Unable to uninstall libcomerr @1.42.9_0, the following ports depend on it:
--->    kerberos5 @1.11.3_0
--->    subversion @1.8.9_0
--->    subversion-perlbindings-5.16 @1.8.9_0
Error: port uninstall failed: Please uninstall the ports that depend on libcomerr first.

您可以在卸载端口本身之前递归地卸载依赖于给定端口的所有端口以解决此问题。为此,请使用 --follow-dependents 标志。

$ sudo port uninstall --follow-dependents libcomerr

You can also override this safety check using the -f (force) flag. Since this will obviously break the dependents you shouldn't do this unless you know what you are doing.

$ sudo port -f uninstall libcomerr

虽然这是卸载的示例,但您可以看到 -f 标志的工作原理。

在安装时,强制标志用于强制激活,以防系统上已经存在您正在安装的端口提供的文件。如果没有 force 标志,MacPorts 将中止安装并警告您;使用标志,MacPorts 将重命名现有文件(附加 .mp_$timestamp)。

如果您之前卸载了某个版本的 MacPorts 但没有清除它提供的所有文件,或者如果使用 MacPorts 构建的第三方安装程序将文件安装到 /opt/local(这是错误的),则可能需要强制执行,但有时还是会发生)。

因为覆盖不是安全行为,所以它不是默认设置。这也是为什么你不应该总是指定 -f.

的原因