Mac 安装Homebrew慢的问题解决

一开始安装,在官网上的命令:java

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

特别的慢,并且执行着就很容易断开,链接不上。因此须要换一种方法。git

打开终端,到本身喜欢的文件夹,执行如下命令,把install文件拉取下来,而且更名为brew_install.shgithub

curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install.sh

而后使用命令行,打开文件,修改里面的配置:vim

cd brew_install.sh

i编辑,找到bash

BREW_REPO = “https://github.com/Homebrew/brew“

替换成下面的:curl

BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"

esc,输入 :wq,保存退出。学习

而后把这个文件拖入终端中,回车,而后就会出现一个权限的问题。url

permission denied: ...

须要在文件夹的目录下,执行如下命令:spa

chmod 777 brew_install.sh

执行完以后,再把文件拖到终端中,而后,回车,执行,再而后就卡住了。命令行

而后须要关掉终端,进入/user/local/Homebrew/Library/文件夹下,删除Taps文件夹,执行如下命令:

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

而后执行如下命令便可:

cd $(brew --repo)

git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

所有换成科大的源应该使用下面的命令,实测只使用前面三个命令,仍是特别卡。

# 替换 Homebrew

git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 替换 Homebrew Core

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 替换 Homebrew Cask

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

# 替换 Homebrew-bottles

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile

source ~/.bash_profile

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc

source ~/.zshrc

下面能够安安静静的安装了:

下面是安装brew cask的步骤,先更新

brew update

输入如下命令:

brew install caskroom/cask/brew-cask

而后若是报错了,就换一个命令:

brew install brew-cask-completion

验证如下是否是成功安装:

brew cask

或者执行

brew tap caskroom/cask

再接着就被卡主了...欲哭无泪,而后解决方法和以前的同样,终端命令行。全都是坑...

cd "$(brew --repo)/Library/Taps/"

cd homebrew

git clone https://mirrors.ustc.edu.cn/homebrew-cask.git

而后再执行换源:

cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask

git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

更新

brew update && brew upgrade && brew cleanup
  • brew update: 更新Homebrew
  • brew upgrade: 完成已安装命令行软件更新
  • brew cleanup: 删除旧版本软件8

btw,brew search已经集成了brew cask search功能,因此别使用brew cask search

此文章仅表明本身(本菜鸟)学习积累记录,或者学习笔记,若有侵权,请联系做者删除。人无完人,文章也同样,文笔稚嫩,在下不才,勿喷,若是有错误之处,还望指出,感激涕零~

技术之路不在一时,山高水长,纵使缓慢,驰而不息。

公众号:秦怀杂货店,有问题能够留言

相关文章
相关标签/搜索