macos 重新安装 Homebrew 的最佳/最安全方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11038028/
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
What is the best/safest way to reinstall Homebrew?
提问by AndrewKS
I am getting issues with permissions in Homebrew: After I installed Node and tried to install npm using the curl command Homebrew tells you to use, it would fail due to EACCESS errors. I checked the node folder and the permissions were a) unowned by a user (I had to chown it) and b) Had no write permissions (I had to chmod 755 it).
我在 Homebrew 中遇到权限问题:在我安装 Node 并尝试使用 Homebrew 告诉您使用的 curl 命令安装 npm 后,它会由于 EACCESS 错误而失败。我检查了节点文件夹,权限是 a) 用户不拥有(我必须 chown 它)和 b)没有写权限(我必须 chmod 755 它)。
I've fixed the issue with NPM, but I had to run its install script as sudo (which is bad!).
我已经用 NPM 解决了这个问题,但我不得不以 sudo 的身份运行它的安装脚本(这很糟糕!)。
I assume I must have installed Homebrew as root or something similar. I am hoping that reinstallation will fix it, but I can't find a source on how to reinstall Homebrew.
我假设我必须以 root 或类似的身份安装 Homebrew。我希望重新安装可以解决它,但我找不到有关如何重新安装 Homebrew 的来源。
When I rerun the installer in Terminal I get:
当我在终端中重新运行安装程序时,我得到:
/usr/local/.git already exists!
采纳答案by kayge
Try running the command
brew doctor
and let us know what sort of output you get
尝试运行命令
brew doctor
并让我们知道您得到什么样的输出
edit: And to answer the title question, this is from their FAQ:
编辑:并回答标题问题,这是来自他们的常见问题解答:
Homebrew doesn't write files outside its prefix. So generally you can just
rm -rf
the folder you installed it in.
Homebrew 不会在其前缀之外写入文件。所以通常你可以只
rm -rf
安装它的文件夹。
So following that up with a clean re-install (following their latest recommended steps) should be your best bet.
因此,进行干净的重新安装(遵循他们最新推荐的步骤)应该是您最好的选择。
回答by Ming C
Brew
already provide a command to uninstall itself:
Brew
已经提供了卸载自身的命令:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
If you failed to run this command due to permission (like run as second user), run again with sudo
如果由于权限(例如以第二个用户身份运行)而无法运行此命令,请使用sudo再次运行
Then you can install again:
然后你可以再次安装:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
回答by William Entriken
Process is to clean up and then reinstall with the following commands:
过程是使用以下命令清理然后重新安装:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"
Notes:
笔记:
- Always check
curl | bash (or ruby)
commands before running them - http://brew.sh/(for installation notes)
- https://raw.githubusercontent.com/Homebrew/install/master/install(for clean up notes, see "Homebrew is already installed")
curl | bash (or ruby)
在运行之前始终检查命令- http://brew.sh/(安装说明)
- https://raw.githubusercontent.com/Homebrew/install/master/install(有关清理说明,请参阅“Homebrew 已安装”)
回答by Nelson
The way to reinstall Homebrew is completely remove it and start over. The Homebrew FAQhas a link to a shell scriptto uninstall homebrew.
重新安装 Homebrew 的方法是完全删除它并重新开始。该家酿常见问题有一个链接到一个shell脚本来卸载自制。
If the only thing you've installed in /usr/local
is homebrew itself, you can just rm -rf /usr/local/* /usr/local/.git
to clear it out. But /usr/local/
is the standard Unix directory for all extra binaries, not just Homebrew, so you may have other things installed there. In that case uninstall_homebrew.sh
is a better bet. It is careful to only remove homebrew's files and leave the rest alone.
如果您安装的唯一东西/usr/local
是自制软件本身,您可以rm -rf /usr/local/* /usr/local/.git
将其清除。但它/usr/local/
是所有额外二进制文件的标准 Unix 目录,不仅仅是 Homebrew,所以你可能在那里安装了其他东西。在这种情况下uninstall_homebrew.sh
是更好的选择。小心地只删除自制软件的文件,而不要管其余的。
回答by Ansari
For Mac OS X Mojave and above
对于 Mac OS X Mojave 及更高版本
To Uninstall Homebrew, run following command:
要卸载 Homebrew,请运行以下命令:
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
To Install Homebrew, run following command:
要安装 Homebrew,请运行以下命令:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
And if you run into Permission denied issue, try running this command followed by install command again:
如果您遇到 Permission denied 问题,请尝试再次运行此命令,然后再运行 install 命令:
sudo chown -R $(whoami):admin /usr/local/* && sudo chmod -R g+rwx /usr/local/*
回答by DILIP KOSURI
For me, this one worked without the sudo access.
对我来说,这个工作没有 sudo 访问权限。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
For more reference, please follow https://gist.github.com/mxcl/323731