当 Brew 认为 link 已经存在时,如何修复 Brew 的 symlink 错误?
How to fix Brew's symlink errors when Brew thinks the link already exists?
请帮助了解正在发生的事情——或者是否需要采取任何措施。我浏览了很多关于处理 brew、节点、符号链接、卸载和重新安装节点、npm、纱线的帖子,尝试过 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/local/lib
中的含义
导致这一切的诱因是我笔记本电脑上的风扇时不时地狂转,通常是在 MAMP 运行.
时
brew cleanup --prune-prefix
(ex- brew prune
) 删除了损坏的符号链接,因此问题应该消失了。
brew link node
抱怨与此无关;这是一个完全不同的命令。这甚至不是错误,只是警告:"you asked me to link node
but it’s already linked" 所以这里一切正常。
Homebrew 在 /usr/local/Cellar
中安装其文件。另一方面,/usr/local/lib
是库常用的共享目录。为了让软件找到安装的 Homebrew 库,它在其中建立了符号链接。
例如,假设您有一个公式 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
,它会删除库文件和符号链接。
可以使用 brew unlink <formula>
(删除它们)和 brew link <formula>
(添加它们)来操作这些 Homebrew 符号链接。 brew install
为您运行 brew link
,因此您不需要。这就是您收到警告的原因:您的节点符号链接已经存在。
brew doctor
执行各种检查,包括 check_for_broken_symlinks
。这会查看 /usr/local/var
或 /usr/local/lib
等目录以查找损坏的符号链接。损坏的符号链接是其目标不存在的符号链接,通常是因为它已被删除。
这里要理解的重点是 Homebrew 查看 所有 符号链接,而不仅仅是它创建的符号链接。损坏的符号链接 可能 会导致问题,这就是 Homebrew 警告您的原因,但如果一切正常,您可以忽略警告。
请帮助了解正在发生的事情——或者是否需要采取任何措施。我浏览了很多关于处理 brew、节点、符号链接、卸载和重新安装节点、npm、纱线的帖子,尝试过 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/local/lib
导致这一切的诱因是我笔记本电脑上的风扇时不时地狂转,通常是在 MAMP 运行.
时brew cleanup --prune-prefix
(ex- brew prune
) 删除了损坏的符号链接,因此问题应该消失了。
brew link node
抱怨与此无关;这是一个完全不同的命令。这甚至不是错误,只是警告:"you asked me to link node
but it’s already linked" 所以这里一切正常。
Homebrew 在 /usr/local/Cellar
中安装其文件。另一方面,/usr/local/lib
是库常用的共享目录。为了让软件找到安装的 Homebrew 库,它在其中建立了符号链接。
例如,假设您有一个公式 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
,它会删除库文件和符号链接。
可以使用 brew unlink <formula>
(删除它们)和 brew link <formula>
(添加它们)来操作这些 Homebrew 符号链接。 brew install
为您运行 brew link
,因此您不需要。这就是您收到警告的原因:您的节点符号链接已经存在。
brew doctor
执行各种检查,包括 check_for_broken_symlinks
。这会查看 /usr/local/var
或 /usr/local/lib
等目录以查找损坏的符号链接。损坏的符号链接是其目标不存在的符号链接,通常是因为它已被删除。
这里要理解的重点是 Homebrew 查看 所有 符号链接,而不仅仅是它创建的符号链接。损坏的符号链接 可能 会导致问题,这就是 Homebrew 警告您的原因,但如果一切正常,您可以忽略警告。