Brew 清理无法删除旧的 python

Brew cleanup unable to remove old python

由于长途旅行,我很长时间没有机会更新或升级 brew,现在当我 运行 brew update 或 brew cleanup 时,我收到以下消息:

 $ brew cleanup
 Removing: /usr/local/Cellar/python/3.6.5... (3,196 files, 75MB)
 Error: Could not remove /usr/local/Cellar/python/3.6.5! Check its 
 permissions.

/usr/local/Cellar/python/3.6.5 中删除 3.6.5 子目录是否安全 root 然后再次进行 brew 清理?

编辑:brew doctor

的输出
Your system is ready to brew.

brew cleanup -vd的输出

<Long output suppressed>   
==> This operation has freed approximately 75MB of disk space.

对于这个特定的错误

因为 homebrew 表明问题可能是权限问题,您可以尝试通过恢复 Homebrew Cellar 目录的正确所有权来解决它。

sudo chown -R your_user_name /usr/local/Cellar/

或更通用的解决方案

sudo chown -R "$USER" "$(brew --prefix)/Cellar"

值得记住的是,您可以使用 brew doctor 检查您的系统是否存在潜在问题。通常,如果有警告,请忽略。