You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行brew cleanup时旧keg清理失败,权限问题求助

执行brew cleanup时旧keg清理失败,权限问题求助

我在运行brew cleanup时碰到了权限相关的报错,具体输出如下:

Error: Could not cleanup old kegs! Fix your permissions on:

% brew cleanup

Removing: /usr/local/Cellar/ansible/6.6.0... (28,050 files, 364MB)

Warning: Directory not empty @ dir_s_rmdir - /usr/local/Cellar/ansible/6.6.0

==> This operation has freed approximately 364MB of disk space.

Error: Could not cleanup old kegs! Fix your permissions on:

/usr/local/Cellar/ansible/6.6.0

% echo $?

1

有没有大佬能帮忙解决下这个问题?


针对这个问题的常见解决步骤:

  • 先用sudo临时运行brew cleanup:虽然平时不推荐用sudo操作Homebrew,但针对权限问题临时用一次通常能解决目录无法删除的问题:

    sudo brew cleanup
    
  • 手动修改目录所有权:如果上面的命令还是不行,就把出问题的目录权限改成当前用户所有:

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

    改完权限后再重新执行brew cleanup,应该就能顺利删除这个旧keg了。

  • 强制手动删除目录:要是还是删不掉,可能是有文件被占用或者权限异常,直接用rm强制删除:

    sudo rm -rf /usr/local/Cellar/ansible/6.6.0
    

    删除完成后再跑一遍brew cleanup,确认没有其他遗留问题。

  • 检查Homebrew整体状态:最后建议运行brew doctor,看看有没有其他潜在的权限或配置问题,按照提示修复即可:

    brew doctor
    

备注:内容来源于stack exchange,提问作者alexus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 08:54:10