【问题标题】:chown: /usr/local: Operation not permitted - issue with brew update /usr/local is not writable - MacOS 10.13.1 high sierrachown: /usr/local: Operation not allowed - brew update /usr/local 的问题不可写 - MacOS 10.13.1 high sierra
【发布时间】:2018-06-22 00:29:21
【问题描述】:

我无法进行 brew 更新,因为我无法 chown /usr/local:

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

基于此:https://github.com/Homebrew/brew/issues/385

我尝试了这 2 个 chown 命令,但没有成功:

$ sudo chown -R $(whoami) $(brew --prefix)
chown: /usr/local: Operation not permitted


$ sudo chown -R $(whoami) /usr/local
chown: /usr/local: Operation not permitted

这是我的/usr/local 列表:

$ cd /usr/local
$ ls -al
total 56
drwxr-xr-x 23 root wheel 736 Dec 2 15:24 .
drwxr-xr-x@ 9 root wheel 288 Oct 26 00:22 ..
-rw-r--r-- 1 megasap wheel 0 Dec 2 15:11 .com.apple.installer.keep
drwxr-xr-x 16 megasap admin 512 Jan 11 14:08 .git
drwxr-xr-x 5 megasap admin 160 Dec 2 15:24 .github
-rw-r--r-- 1 megasap admin 1112 Aug 11 2016 .gitignore
-rw-r--r-- 1 megasap admin 253 Aug 11 2016 .travis.yml
-rw-r--r-- 1 megasap admin 291 Aug 11 2016 .yardopts
-rw-r--r-- 1 megasap admin 3161 Aug 11 2016 CODEOFCONDUCT.md
drwxr-xr-x 35 megasap admin 1120 Jan 11 11:35 Cellar
-rw-r--r-- 1 megasap admin 1241 Jan 26 2016 LICENSE.txt
drwxr-xr-x 9 megasap admin 288 Dec 2 15:25 Library
-rw-r--r-- 1 megasap admin 5451 Aug 11 2016 README.md
drwxr-xr-x 262 megasap admin 8384 Jan 11 23:09 bin
drwxr-xr-x 11 megasap admin 352 Dec 2 15:25 etc
drwxr-xr-x 57 megasap staff 1824 Dec 2 15:25 include
drwxr-xr-x 102 megasap staff 3264 Dec 2 15:25 lib
drwx------ 4 megasap wheel 128 Dec 2 15:24 libexec
drwxr-xr-x 3 megasap admin 96 Dec 2 15:23 n
drwxr-xr-x 34 megasap admin 1088 Dec 2 15:25 opt
drwxr-xr-x 8 megasap admin 256 Dec 2 15:24 sbin
drwxr-xr-x 16 megasap admin 512 Dec 2 15:25 share
drwxr-xr-x 8 megasap admin 256 Dec 2 15:25 var

我使用的是 macOS 10.13.1 high sierra。

【问题讨论】:

标签: macos homebrew chown


【解决方案1】:

使用 https://github.com/Homebrew/install 卸载和安装 Homebrew

【讨论】:

  • 不需要先卸载,重新运行安装即可
【解决方案2】:

显然这是由于 mac 的“系统完整性配置”。要解决此问题,您需要将机器重新启动到恢复模式(重新启动机器并按住 ⌘+R)进入实用程序 > 终端并输入命令:

csrutil disable
reboot

然后运行你的 chown 命令。我猜它建议在更改权限以重新启用安全性后重新启用它。

完全披露,我自己还没有尝试过 - 今天晚些时候我会试一试,因为它是一个巨大的 PITA。作为记录,我只是尝试安装 python3。

Original information

【讨论】:

    【解决方案3】:

    你不妨试试:

    sudo chown -R $(whoami) $(brew --prefix)/*

    更多信息请见:https://github.com/Homebrew/brew/issues/3228

    【讨论】:

      【解决方案4】:

      重新安装 Homebrew 对我有用

      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
      

      【讨论】:

        猜你喜欢
        • 2013-01-09
        • 2018-03-09
        • 2015-12-23
        • 2014-12-17
        • 2017-04-03
        • 2018-06-23
        • 2018-05-25
        • 1970-01-01
        • 2019-08-07
        相关资源
        最近更新 更多