Mac系统升级失败,心情烦躁。

摘要

昨天换电脑,升级软件,却遇到了brew update的问题,让我感到十分苦恼和无助。

正文

Mac OSX系统软件homebrew update Fetching failed难题解决方法

1. brew update error

(i) 难题发生及状况叙述

昨日换了台电脑上,有一些手机软件必须重装或升级一下,碰到了下边的难题

cv@xys-MacBook-Pro ~ % brew update
touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied
error: cannot open .git/FETCH_HEAD: Permission denied
touch: /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask/.git/FETCH_HEAD: Permission denied
/usr/local/Homebrew/Library/Homebrew/cmd/update.sh: line 522: /usr/local/Homebrew/.git/UPDATE_FAILED: Permission denied
error: cannot open .git/FETCH_HEAD: Permission denied
touch: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/FETCH_HEAD: Permission denied
/usr/local/Homebrew/Library/Homebrew/cmd/update.sh: line 522: /usr/local/Homebrew/.git/UPDATE_FAILED: Permission denied
error: cannot open .git/FETCH_HEAD: Permission denied
/usr/local/Homebrew/Library/Homebrew/cmd/update.sh: line 522: /usr/local/Homebrew/.git/UPDATE_FAILED: Permission denied
touch: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/FETCH_HEAD: Permission denied
error: cannot open .git/FETCH_HEAD: Permission denied
/usr/local/Homebrew/Library/Homebrew/cmd/update.sh: line 522: /usr/local/Homebrew/.git/UPDATE_FAILED: Permission denied
fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied
fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied
error: could not lock config file .git/config: Permission denied
Already up-to-date.

(ii) 解决方法

在StackOverflow上找到一个相近的难题,用高赞的回应解决了这个问题。

立即根据更改 /usr/local 的隶属客户从而处理管理权限难题。

不一样的版本号应用的命令略有不同,如果是 macOS High Sierra 或高些版本号的系统软件的客户,应用下边的命令能够改动隶属权,

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

如果是 macOS Sierra 或更低版的系统软件的客户,应用下边的命令

~$ sudo chown -R $(whoami) /usr/local

查询本系统版本信息,能够根据点击左上方iPhone Logo ==> 关于本机,就能见到系统软件版本信息以及名字。版本信息中间的高矮能够根据WikiPedia上边记述的版本号与名字相匹配目录来查看。

Public Beta: "Kodiak", Released on September 13, 2000
Version 10.0: "Cheetah", Released on March 24, 2001
Version 10.1: "Puma", Released on September 25, 2001
Version 10.2: "Jaguar", Released on August 23, 2002
Version 10.3: "Panther", Released on October 24, 2003
Version 10.4: "Tiger", Released on April 29, 2005
Version 10.5: "Leopard", Released on October 26, 2007
Version 10.6: "Snow Leopard", Released on August 28, 2009
Version 10.7: "Lion", Released on July 20, 2011
Version 10.8: "Mountain Lion", Released on July 25, 2012
Version 10.9: "Mavericks", Released on October 22, 2013
Version 10.10: "Yosemite", Released on October 16, 2014
Version 10.11: "El Capitan", Released on June 8, 2015
Version 10.12: "Sierra", Released on June 13, 2016
Version 10.13: "High Sierra", Released on June 5, 2017
Version 10.14: "Mojave", Released on June 4, 2018
Version 10.15: "Catalina", Released on June 3, 2019
Version 11: "Big Sur", Released on June 22, 2020

2. brew update “Fetching homebrew-cask failed!”

(i) 难题叙述

虽然管理权限难题用以上方式 解决了,但事后实行时又碰到了一点难题,此次是主要是Homebrew的在其中2个构成部分homebrew-caskhomebrew-core造成的,发生了以下所显示的 “Fetching failed” 不正确。

cv@xys-MBP ~ % brew update
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
Updated 2 taps (homebrew/cask and caskroom/cask).

(ii) 解决方法

试着了一些方式 都没处理,最终挑选重装 Homebrew,终究没什么难题是重新安装不可以处理的,如果有,就连系统软件一起重新安装…总的来说,重新安装以后的确没有问题了(\汗)。

最先自然是卸载掉现有的安裝版本号,命令是 /bin/bash -c "$(curl -fsSL https://raw.GitHubusercontent.com/Homebrew/install/HEAD/uninstall.sh)",結果以下。

cv@xys-MBP ~ % /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Warning: The Ruby Homebrew uninstaller is now deprecated and has been rewritten in
Bash. Please migrate to the following command: 
  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443

cv@xys-MBP ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)

然后自然是安裝最新版本,命令是/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)",結果以下,正中间有一次必须依据自身的要求挑选源并键入 root 登陆密码。

cv@xys-MBP ~ % /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

               逐渐实行Brew全自动程序安装
              [cunkai.wang@foxmail.com]
           ['2021-05-20 17:53:17']['11.3']
        https://zhuanlan.zhihu.com/p/111014448


挑选一个免费下载镜像系统,比如中国科技大学,键入1回车键。
源有时不稳定,假如git克隆出错再次运作脚本制作挑选源。cask非务必,有一部分人必须。
1、中国科技大学免费下载源 2、清华免费下载源 3、北京外国语大学免费下载源  4、腾讯下载源(不强烈推荐) 5、阿里免费下载源(不强烈推荐 缺乏cask源)

输入您编号:

我选择了中国科技大学免费下载源,键入 1 回车键就可以。


  你挑选了我国科技进步高校免费下载源

!!!此脚本制作即将删掉以前的brew(包含它下载的软件),请自主备份数据。
->是不是从现在起实行脚本制作(N/Y)

是不是实行,挑选是,键入 Y 回车键再次。然后输入支付密码后一切正常状况下就能一直运作到最终了,假如中中断了依据提醒开展相对应的实际操作就可以。

--> 脚本制作逐渐实行
 Mac os设定密码方式 :
  (设定密码:在左上方苹果图标->系统软件偏好设置->客户与群聊->修改密码)
  (假如提醒This incident will be reported. 在客户与群聊中查询是不是管理人员)
==> 根据指令删掉以前的brew、建立一个新的Homebrew文件夹
输入您密码,键入全过程无法显示,键入完后回车键
逐渐实行
  ---备份数据要删掉的/usr/local/Homebrew到系统桌面....
   ---/usr/local/Homebrew 备份数据进行
-> 创建文件夹 /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /usr/local/Homebrew
此流程取得成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown cv /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew
git version 2.20.1

网络速度感觉慢能够ctrl c或control c再次运作脚本制作挑选免费下载源
==> 复制Homebrew基本上文档

未发觉Git代理商(归属于一切正常情况)
Cloning into '/usr/local/Homebrew'...
remote: Enumerating objects: 191263, done.
remote: Total 191263 (delta 0), reused 0 (delta 0) | 10.55 MiB/s   
Receiving objects: 100% (191263/191263), 48.84 MiB | 10.64 MiB/s, done.
Resolving deltas: 100% (142769/142769), done.
此流程取得成功
--建立Brew所必须的文件目录
运行代码 ==> /usr/bin/sudo /bin/chmod u rwx /usr/local/bin/brew
运行代码 ==> /usr/bin/sudo /bin/chmod g rwx /usr/local/bin/brew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /usr/local/sbin /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /bin/chmod g rwx /usr/local/sbin /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/sbin/chown cv /usr/local/sbin /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/sbin /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R cv:admin /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /Users/cv/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /bin/chmod g rwx /Users/cv/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R cv /Users/cv/Library/Caches/Homebrew
--依靠文件目录脚本制作运作进行
==> 建立brew的配角
==> 复制Homebrew Core
这里假如表明Password表明必须再度键入密码,键入完后回车键
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 960954, done.
remote: Total 960954 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (960954/960954), 380.33 MiB | 10.66 MiB/s, done.
Resolving deltas: 100% (660866/660866), done.
Checking out files: 100% (5914/5914), done.
此流程取得成功
==> 复制Homebrew Cask 图形界面手机软件
  这里假如表明Password表明必须再度键入密码,键入完后回车键

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 624249, done.
remote: Total 624249 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (624249/624249), 260.95 MiB | 9.69 MiB/s, done.
Resolving deltas: 100% (445746/445746), done.
此流程取得成功
==> 复制Homebrew services 管理服务的起停

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 1141, done.
remote: Counting objects: 100% (1141/1141), done.
remote: Compressing objects: 100% (495/495), done.
remote: Total 1141 (delta 484), reused 1141 (delta 484), pack-reused 0
Receiving objects: 100% (1141/1141), 331.50 KiB | 330.00 KiB/s, done.
Resolving deltas: 100% (484/484), done.
此流程取得成功
==> 配备中国镜像源HOMEBREW BOTTLE
sed: /Users/cv/.zprofile: No such file or directory
系统变量载入->/Users/cv/.zprofile
此流程取得成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown cv /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew

==> 安裝进行,brew版本号

Homebrew 3.1.8-50-g76c4767-dirty
Homebrew/homebrew-core (git revision 832bb8b966; last commit 2021-05-20)
Homebrew/homebrew-cask (git revision f397055044; last commit 2021-05-20)
Brew早期配备取得成功
电脑操作系统版本号:11.3
All user-space services OK, nothing cleaned...

  ==> brew update-reset

==> Fetching /usr/local/Homebrew...

==> Resetting /usr/local/Homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.

==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...

==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...   
Checking out files: 100% (3977/3977), done.
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.

==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...

==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Checking out files: 100% (5659/5659), done.
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.

==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services...

==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.


Brew自动安装程序执行进行
中国详细地址早已配备进行

  桌面上的Old_Homebrew文件夹,大概看一下没有你必须的能够删掉。

基本详细介绍好多个brew指令
当地软件库目录:brew ls
搜索手机软件:brew search Google(在其中google更换为要搜索的关键词)
查询brew版本号:brew -v  升级brew版本号:brew update
安裝cask手机软件:brew install --cask firefox 把firefox换为你需要安裝的

热烈欢迎鼠标右键点一下下边详细地址-开启URL 来给点个赞
https://zhuanlan.zhihu.com/p/111014448 

 重新启动终端设备 或是 运作 source /Users/cv/.zprofile   不然很有可能没法应用

安裝进行后依照提醒运作 source 指令

cv@xys-MBP ~ % source ~/.zprofile

到此重新安装全过程完毕,逐渐一切正常应用 Homebrew。

(全文完)


参考文献

[1] brew update fails with “Permission denied” error (https://stackoverflow.com/questions/50267510/brew-update-fails-with-permission-denied-error/50268978)

[2] macOS version history (https://en.wikipedia.org/wiki/MacOS_version_history)

[3] mac下Homebrew安裝Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed出错解决方案 (http://www.cxyzjd.com/article/Jiangzhiqi4551/116174524)

[4] Mac 下 brew 转换为中国源 (https://cloud.tencent.com/developer/article/1614039)

文中创作者 :phillee
发布日期 :2021年5月20日
文中连接https://www.cnblogs.com/phillee/p/14788909.html
版权声明 :随意转截-非商业-非衍化-维持落款(艺术创意共享资源3.0授权文件/CC BY-NC-SA 3.0)。转截请标明来源!
仅限于自己水准,假如文章内容和编码有描述不妥,还请鼎力相助。

关注不迷路

扫码下方二维码,关注宇凡盒子公众号,免费获取最新技术内幕!

温馨提示:如果您访问和下载本站资源,表示您已同意只将下载文件用于研究、学习而非其他用途。
文章版权声明 1、本网站名称:宇凡盒子
2、本站文章未经许可,禁止转载!
3、如果文章内容介绍中无特别注明,本网站压缩包解压需要密码统一是:yufanbox.com
4、本站仅供资源信息交流学习,不保证资源的可用及完整性,不提供安装使用及技术服务。点此了解
5、如果您发现本站分享的资源侵犯了您的权益,请及时通知我们,我们会在接到通知后及时处理!提交入口
0

评论0

请先

站点公告

🚀 【宇凡盒子】全网资源库转储中心

👉 注册即送VIP权限👈

👻 全站资源免费下载✅,欢迎注册!

记得 【收藏】+【关注】 谢谢!~~~

立即注册
没有账号?注册  忘记密码?

社交账号快速登录