mac安装brew

绝地灬酷狼 2022-05-30 03:47 450阅读 0赞

一,安装brew

1,安装brew

curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local —strip 1

2,安装完成后执行

brew

提示:Please run brew update!

3,按照提示更新,执行

brew update

报错:Error: /usr/local must be writable!

4,赋给/usr/local目录权限,执行sudo chown -R $(whoami) /usr/local,即

报错:Operation not permitted

发现是El Capitan(10.11) 加入了Rootless机制,很多系统目录不再能够随心所欲的读写了,即使设置 root 权限也不行。

以下路径无法写和执行

  1. /System
  2. /bin
  3. /sbin
  4. /usr (except /usr/local)
  • 1
  • 2
  • 3
  • 4

需要关闭rootless

如何关闭

重启按住 Command+R,进入恢复模式,打开Terminal

  1. csrutil disable
  • 1

sudo chown -R caositing /usr/local

其中caositing为系统当前用户名。

5,再次执行

brew update

提示:

remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0

HEAD is now at c3f959d Merge pull request #1542 from woodruffw/deprecate-utils-json

To restore the stashed changes to /usr/local run:

‘cd /usr/local && git stash pop’

==> Homebrew has enabled anonymous aggregate user behaviour analytics

Read the analytics documentation (and how to opt-out) here:

https://git.io/brew-analytics

==> Tapping homebrew/core

Cloning into ‘/usr/local/Library/Taps/homebrew/homebrew-core’…

remote: Counting objects: 3757, done.

remote: Compressing objects: 100% (3647/3647), done.

remote: Total 3757 (delta 13), reused 305 (delta 1), pack-reused 0

Receiving objects: 100% (3757/3757), 3.00 MiB | 30.00 KiB/s, done.

Resolving deltas: 100% (13/13), done.

Checking connectivity… done.

Tapped 3636 formulae (3,784 files, 9.3M)

Already up-to-date.

Error: Could not link:

/usr/local/share/doc/homebrew

Please delete these paths and run `brew update`.

==> Migrating HOMEBREW_REPOSITORY (please wait)…

Error: Could not link:

/usr/local/share/doc/homebrew

Please delete these paths and run `brew update`.

==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!

Homebrew no longer needs to have ownership of /usr/local. If you wish you can

return /usr/local to its default ownership with:

sudo chown root:wheel /usr/local

6,按照提示删除/usr/local/share/doc/homebrew,执行

rm -r -f /usr/local/share/doc/homebrew

7,再次执行

brew update

安装更新成功!

发表评论

表情:
评论列表 (有 0 条评论,450人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Macbrew安装

    1.安装,打开终端,复制粘贴,大约1分钟左右,下载完成,过程中需要输入密码,其他无需任何操作: /usr/bin/ruby -e “$(curl -fsSL https://