homebrew 无法安装提示不能在根目录下使用

首先提示一点:能谷歌绝对不要百度解决问题。

1.昨天百度了一天,都都没有找到解决方案。因为昨天是20161130日,我的蓝灯翻墙软件的流量使用光了。悲催~

2.今天是20161201日,我可以免费使用蓝灯了。就一个谷歌第一个就提供了解决方案。可以说是2分钟内就解决了。

所以,期待谷歌进入中国吧。

3.开始记博客:

homebrew 无法安装,提示不能在根目录下使用。

Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

解决思路就是给当前用户添加目录权限:

sudo chown -R $(whoami) /usr/local

然后再安装你需要的软件通过:brew install softname;

不过,如果还是遇到不能安装的情况,就根据提示内容再次给当前用户赋予相应的目录权限(这里系统会提示),你只要根据提示操作就行了。

在我执行上面的命令之后,我想安装软件:

又提示了一下错误:

Error: /usr/local/Cellar is not writable. You should change the
ownership and permissions of /usr/local/Cellar back to your
user account:
  sudo chown -R $(whoami) /usr/local/Cellar
Error: Cannot write to /usr/local/Cellar

我根据提示再次执行命令:

sudo chown -R $(whoami) /usr/local/Cellar

然后,再次安装我需要的软件,问题解决了。

如果后面还有错误提示,就再次根据提示操作。直到问题解决。

谷歌就是好!

原文地址:https://www.cnblogs.com/xiaohaillong/p/6120913.html