gpt4 book ai didi

homebrew - 当 Brew 认为链接已经存在时,如何修复 Brew 的符号链接(symbolic link)错误?

转载 作者:行者123 更新时间:2023-12-02 17:04:08 35 4
gpt4 key购买 nike

请帮助了解正在发生的事情,或者是否需要采取任何措施。我看过很多关于处理 brew、节点、符号链接(symbolic link)、卸载和重新安装节点、npm、 yarn 的帖子,尝试过 brew cleanup。当 brew doctor 产生这些警告时——

 Warning: Broken symlinks were found. Remove them with `brew prune`:
/usr/local/lib/node_modules/npm/node_modules/.bin/JSONStream
/usr/local/lib/node_modules/npm/node_modules/.bin/errno
/usr/local/lib/node_modules/npm/node_modules/.bin/is-ci
/usr/local/lib/node_modules/npm/node_modules/.bin/node-gyp
/usr/local/lib/node_modules/npm/node_modules/.bin/opener
/usr/local/lib/node_modules/npm/node_modules/.bin/qrcode-terminal
/usr/local/lib/node_modules/npm/node_modules/.bin/rc
/usr/local/lib/node_modules/npm/node_modules/.bin/semver
/usr/local/lib/node_modules/npm/node_modules/.bin/sshpk-conv
/usr/local/lib/node_modules/npm/node_modules/.bin/sshpk-sign
/usr/local/lib/node_modules/npm/node_modules/.bin/sshpk-verify
/usr/local/lib/node_modules/npm/node_modules/.bin/uuid
/usr/local/lib/node_modules/npm/node_modules/.bin/which

当我尝试 brew prune 时,我得到:

newmbp$ brew link node
Warning: Already linked: /usr/local/Cellar/node/10.11.0

我注意到文件(要链接或取消链接)位于不同的文件夹中,但一直在努力理解将文件放在 /usr/local/Cellar/中的含义usr/本地/lib

导致这一切的促发因素是我笔记本电脑上的风扇时不时地狂转,通常是在 MAMP 运行时。

最佳答案

brew cleanup --prune-prefix (ex- brew prune) 删除了损坏的符号链接(symbolic link),因此问题应该消失了。

事实brew link node投诉与此无关;这是一个完全不同的命令。这甚至不是一个错误,只是一个警告:“你让我链接 node 但它已经链接了”所以这里一切正常。


Homebrew 将其文件安装在 /usr/local/Cellar 中.另一方面,/usr/local/lib是库常用的共享目录。为了让软件找到已安装的 Homebrew 库,它会在其中建立符号链接(symbolic link)。

例如,假设您有一个公式 foo安装库的 1.2.3 版 bar .运行后 brew install foo你应该得到这样的东西:

# the library files
/usr/local/Cellar/foo/1.2.3/lib/bar
# a symlink to the library files from /usr/local/lib
/usr/local/lib/bar -> /usr/local/Cellar/foo/1.2.3/lib/bar

如果你brew uninstall foo , 它会删除库文件和符号链接(symbolic link)。

这些 Homebrew 符号链接(symbolic link)可以用 brew unlink <formula> 操作(删除它们)和 brew link <formula> (添加它们)。 brew install运行 brew link为你,所以你不需要。这就是您收到警告的原因:您的节点符号链接(symbolic link)已经存在。

brew doctor执行各种检查,包括 check_for_broken_symlinks .这一个查看目录,例如 /usr/local/var/usr/local/lib对于损坏的符号链接(symbolic link)。损坏的符号链接(symbolic link)是其目标不存在的符号链接(symbolic link),通常是因为它已被删除。

这里要理解的重点是 Homebrew 查看所有符号链接(symbolic link),而不仅仅是它创建的符号链接(symbolic link)。损坏的符号链接(symbolic link)可能会导致问题,这就是 Homebrew 警告您的原因,但如果一切正常,您可以忽略该警告。

关于homebrew - 当 Brew 认为链接已经存在时,如何修复 Brew 的符号链接(symbolic link)错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52610026/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com