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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 09:15:22  来源:igfitidea点击:

What is the best/safest way to reinstall Homebrew?

macoshomebrew

提问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 doctorand 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 -rfthe 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

Brewalready 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:

笔记:

回答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/localis homebrew itself, you can just rm -rf /usr/local/* /usr/local/.gitto 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.shis 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

更多参考请关注 https://gist.github.com/mxcl/323731

enter image description here

在此处输入图片说明