安装brew遇到的问题解答,Operation not permitted问题解决

安装brew遇到的问题解答,Operation not permitted问题解决
一,安装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,即

sudo chown -R fxp /usr/local

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

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

其实这样依旧不能解决安装失败的问题,如果项顺利的安装成功,可能是你第一次安装失败了,又安装了一次,下面是撤销安装的命令,以及重新安装的命令
在brew update的时候出现报错:Error: /usr/local must be writable! 错误,对于高版本的OS来说,是解决不了的,会报chown: /usr/local: Operation not permitted错误。

后来在https://stackoverflow.com/questions/46459152/cant-chown-usr-local-for-homebrew-in-osx-10-13-high-sierra网页上给出了解决办法,下面简单总结一下:

先卸载已安装的homebrew,命令如下:

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)”
然后重新安装:
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

博主第一次写的博客,万分激动,这个问题弄了好久

猜你喜欢

转载自blog.csdn.net/lc574260570/article/details/81603841
今日推荐