/usr/local/ 上不允许操作,无法安装 Homebrew

/usr/local/ 上不允许操作,无法安装 Homebrew

寻求一些关于如何修复/usr/bin目录权限的指导。事实上,我最近在我的计算机上进行了数据恢复,我必须将我的整个主目录复制到一台新 Mac 上。

此时,我注意到,/usr/local迁移数据之前文件夹中的旧二进制文件已无法运行。

我也没有brew,而且无法安装它。

尝试chown /usr/local也失败了

% sudo chown -R "$USER":admin /usr/local
chown: /usr/local: Operation not permitted

当我注意到 brew 未安装时,这种情况首次发生。当我尝试安装 brew 时,出现以下信息:

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password).
Password:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/bin
/usr/local/sbin

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/sbin
mkdir: /usr/local/bin: Not a directory
mkdir: /usr/local/sbin: Not a directory
Failed during: /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/sbin

这是我的ls -aleO@ /usr/local

total 52960
drwxr-xr-x  14 root             wheel  sunlnk                 448 Feb 24 19:19 .
drwxr-xr-x@ 11 root             wheel  restricted,hidden      352 Feb 18 16:51 ..
    com.apple.rootless         0 
drwxr-xr-x   2 myuser.user  admin  -                       64 Feb 24 19:19 Caskroom
drwxr-xr-x   2 myuser.user  admin  -                       64 Feb 24 19:19 Cellar
drwxrwxr-x   2 myuser.user  admin  -                       64 Feb 24 19:19 Frameworks
-rwxrwxr-x@  1 myuser.user  admin  -                 12434524 Feb 23 21:11 bin
    com.apple.quarantine          57 
drwxrwxr-x   2 myuser.user  admin  -                       64 Feb 24 19:19 etc
drwxr-xr-x  20 myuser.user  admin  -                      640 Feb 16 11:12 go
drwxrwxr-x   2 myuser.user  admin  -                       64 Feb 24 19:19 include
drwxrwxr-x   2 myuser.user  admin  -                       64 Feb 24 19:19 lib
drwxrwxr-x   2 myuser.user  admin  -                       64 Feb 24 19:19 opt
-rwxrwxr-x@  1 myuser.user  admin  -                 14033312 Feb 23 21:44 sbin
    com.apple.quarantine          57 
drwxrwxr-x   3 myuser.user  admin  -                       96 Feb 24 19:19 share
drwxrwxr-x   3 myuser.user  admin  -                       96 Feb 24 19:19 var```

答案1

我需要删除 /usr/local/bin 和 /usr/local/sbin。删除后,我就可以安装 homebrew 了。看来我已经有指向此目录的符号链接。

相关内容