没有这样的桶:/usr/local/Cellar/git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28225045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No such keg: /usr/local/Cellar/git
提问by flareartist
I have been struggling with this for a few hours. I am on a Mac using Yosemite. I had homebrew installed, and was using git just fine. I tried doing $git add -i
and I got this error:
我已经为此苦苦挣扎了几个小时。我在使用 Yosemite 的 Mac 上。我安装了自制软件,并且使用 git 就好了。我尝试这样做$git add -i
,但出现此错误:
Can't locate Git.pm in @INC (@INC contains:
在@INC 中找不到 Git.pm(@INC 包含:
So I followed the instructions here: Can't locate Git.pm in @INC
所以我按照这里的说明操作: Can't locate Git.pm in @INC
$brew uninstall git
worked fine, but after I tried to $brew install git
I've been stuck in a terrible cycle.
$brew uninstall git
工作正常,但在我尝试之后,$brew install git
我陷入了一个可怕的循环。
% brew install git
Error: git-git already installed
To install this version, first `brew unlink git'
% brew unlink git
Error: No such keg: /usr/local/Cellar/git
% brew link git
Error: No such keg: /usr/local/Cellar/git
% git --version
git version 1.9.3 (Apple Git-50)
% brew upgrade git
==> Upgrading 1 outdated package, with result:
git 2.2.2
Error: /usr/local/Library/LinkedKegs/git is not a valid keg
% brew install git
Error: git-git already installed
To install this version, first `brew unlink git'
%
I just want to get homebrew & git back to normal and linked to the correct repo again. I'm really rough around the edges at this stuff, so any help would be greatly appreciated!
我只想让自制软件和 git 恢复正常并再次链接到正确的存储库。我在这方面真的很粗糙,所以任何帮助将不胜感激!
回答by brownmike
Give another go at force removing the brewed version of git
再次强行删除 git 的酿造版本
brew uninstall --force git
Then cleanup any older versions and clear the brew cache
然后清理所有旧版本并清除 brew 缓存
brew cleanup --force -s git
Remove any dead symlinks
删除任何无效的符号链接
brew cleanup --prune-prefix
Then try reinstalling git
然后尝试重新安装git
brew install git
If that doesn't work, I'd remove that installation of Homebrew altogether and reinstall it. If you haven't placed anything else in your brew --prefix
directory (/usr/local
by default), you can simply rm -rf $(brew --prefix)
. Otherwise the Homebrew wiki recommends using a script at https://gist.github.com/mxcl/1173223#file-uninstall_homebrew-sh
如果这不起作用,我会完全删除 Homebrew 的安装并重新安装它。如果你没有在你的brew --prefix
目录中放置任何其他东西(/usr/local
默认情况下),你可以简单地rm -rf $(brew --prefix)
. 否则 Homebrew wiki 建议使用https://gist.github.com/mxcl/1173223#file-uninstall_homebrew-sh 上的脚本
回答by Oleksandr
Os X Mojave 10.14 has:
OS X Mojave 10.14 具有:
Error: The Command Line Tools header package must be installed on Mojave.
错误:必须在 Mojave 上安装命令行工具头文件包。
Solution. Go to
解决方案。去
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
location and install the package manually. And brew will start working and we can run:
位置并手动安装包。brew 将开始工作,我们可以运行:
brew uninstall --force git
brew cleanup --force -s git
brew prune
brew install git
回答by Giri
Had a similar issue while installing "Lua" in OS X using homebrew. I guess it could be useful for other users facing similar issue in homebrew.
使用自制软件在 OS X 中安装“Lua”时遇到了类似的问题。我想这对于在自制软件中面临类似问题的其他用户可能很有用。
On running the command:
在运行命令时:
$ brew install lua
$ brew install lua
The command returned an error:
命令返回错误:
Error: /usr/local/opt/lua is not a valid keg
(in general the error can be of /usr/local/opt/ is not a valid keg
错误: /usr/local/opt/lua is not a valid keg
(通常错误可能是 /usr/local/opt/ is not a valid keg
FIXED it by deleting the file/directory it is referring to, i.e., deleting the "/usr/local/opt/lua" file.
通过删除它所指的文件/目录来修复它,即删除“/usr/local/opt/lua”文件。
root-user # rm -rf /usr/local/opt/lua
根用户 # rm -rf /usr/local/opt/lua
And then running the brew install command returned success.
然后运行 brew install 命令返回成功。