文章目录
1.官网获取下载命令
http://brew.sh/
PS:卸载同上,官网也提供有命令卸载 常用命令
简单使用
安装软件:brew install 软件名,例:brew install wget
搜索软件:brew search 软件名,例:brew search wget
卸载软件:brew uninstall 软件名,例:brew uninstall wget
更新所有软件:brew update
更新具体软件:brew upgrade 软件名 ,例:brew upgrade git
显示已安装软件:brew list
查看软件信息:brew info/home 软件名 ,例:brew info git / brew home git
PS:brew home指令是用浏览器打开官方网页查看软件信息
查看哪些已安装的程序需要更新: brew outdated
显示包依赖:brew reps
显示帮助:brew help
2.网络好~直接输入官网命令后就能安装好了
3.网络不好~看下面步骤
3.1 获取install文件
官网命令是:
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
两种方式获取:
1, 在浏览器中打开命令中https://raw.githubusercontent.com/Homebrew/install/master/install
页面,将页面内容另存文件名为brew_install.rb
2. 直接命令获取文件curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install.rb
3.2 更换下载源
打开 brew_install.rb 文件,修改如下:
找到如下代码:
BREW_REPO = “https://github.com/Homebrew/brew“.freeze
CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze
更改为:
BREW_REPO = “https://mirrors.ustc.edu.cn/brew.git “.freeze
CORE_TAP_REPO = “https://mirrors.ustc.edu.cn/homebrew-core.git“.freeze
PS:新版本HomeBrew可能没有CORE_TAP_REPO这句代码,如果没有不用新增。
3.3 执行脚本安装
执行脚本
/usr/bin/ruby brew_install.rb
此时脚本应该停在
==> Tapping homebrew/core
Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core’…
解决方法,手动执行下面这句命令,更换为中科院的镜像:
1. git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
2. 把homebrew-core的镜像地址也设为中科院的国内镜像
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
3.4 校验安装
执行更新
brew update
检查无错误
brew doctor
HomeBrew is ok。
4. 安装时,部分依赖安装包,下载失败解决
报错信息举例:
PS:安装时,只要时部分软件下载不完整导致的无法安装,都可以使用这种方式解决
DownloadError: Failed to download resource "gdbm"
Download failed: https://ftp.gnu.org/gdbm/gdbm-1.18.1.tar.gz
原理:
安装homebrew时,会将下载的依赖安装包放到缓存目录;
如果安装过程下载某些软件失败,可以直接手动下载好软件包,保持缓存目录中软件名字的uuid不变,将其放到homebrew缓存目录中即可使用
1⃣️. 查看Homebrew缓存目录
brew --cache
> /Users/mac/Library/Caches/Homebrew/
2⃣️. 进入到/Users/mac/Library/Caches/Homebrew/downloads
目录
将下载失败的软件包名字中的uuid字符串复制;
将下载好的软件包重命名(保持名称中的uuid字符串相同)
3⃣️. 重新安装即可
/usr/bin/ruby brew_install
ok!