柚子快报激活码778899分享:MacOS安装Homebrew

http://yzkb.51969.com/

目录

一、Homebrew介绍

1、Homebrew的好处

2、安装方式

方法一:brew官方安装

方法二:brew 镜像安装脚本(亲测最快速最有效)

二、安装步骤

1、安装国内镜像

2、配置路径

3、必备配置、按需配置

1.必备设置

2.按需设置

4、Homebrew 安装时如何避坑

1.若出现 Error: Checksum mismatch.

2.若卡在了Cloning into...

三、Homebrew组成

四、Homebrew 基本用法有哪些

一、Homebrew介绍

1、Homebrew的好处

macOS的包管理器,安装brew之后,仅需执行相应的命令,就能下载安装需要的软件包,可以省掉自己去下载、解压、拖拽(安装)等繁琐的步骤。

比如nginx反向代理服务器等,打开终端执行以下命令即可安装:

brew install 某某包名字

2、安装方式

方法一:brew官方安装

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

这时很可能会出现一个问题: 要么下载很慢,要么直接提示这个

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

不要慌,这是因为官方安装包的下载地址在国外,被限制了 。

此时需要换一种科学高效的安装方法。

方法二:brew 镜像安装脚本(亲测最快速最有效)

/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"

该脚本用了中科大镜像加速访问,仅修改仓库地址部分,不会产生安全隐患。 关于中科大所提供的 Homebrew 镜像服务 https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git

二、安装步骤

1、安装国内镜像

该脚本用了中科大镜像加速访问,仅修改仓库地址部分,不会产生安全隐患。 关于中科大所提供的 Homebrew 镜像服务 https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git

/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"

2、配置路径

chenmingsong@chenmingsongdeMacBook-Pro ~ % echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/chenmingsong/.zprofile

chenmingsong@chenmingsongdeMacBook-Pro ~ % eval "$(/opt/homebrew/bin/brew shellenv)"

3、必备配置、按需配置

前面已经提到,Homebrew通常用来下载软件的,但它在安装软件时非常慢。为了提升安装速度,需要更改 Homebrew 的安装源,将其替换成国内镜像。

这里用的是由中科大负责托管维护的 Homebrew 镜像。其中,前两个为必须配置的项目,后两个可按需配置。

1.必备设置

替换 brew.git:

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

替换 homebrew-core.git:

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

2.按需设置

替换 homebrew-cask.git:

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

替换homebrew-bottles:

首先要先区分你的mac用哪种终端工具,如果是 bash,则执行:

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

若是 zsh,则执行:

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

4、Homebrew 安装时如何避坑

1.若出现 Error: Checksum mismatch.

报错代码如下:

curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

Error: Checksum mismatch.

Expected: b065e5e3783954f3e65d8d3a6377ca51649bfcfa21b356b0dd70490f74c6bd86

Actual: e8a348fe5d5c2b966bab84052062f0317944122dea5fdfdc84ac6d0bd513c137

Archive: /Users/joyce/Library/Caches/Homebrew/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz

To retry an incomplete download, remove the file above.

Error: Failed to install Homebrew Portable Ruby (and your system version is too old)!

Failed during: /usr/local/bin/brew update --force

这里是由Homebrew目录下的portable-ruby-2.6.3_2.yosemite.bottle.tar.gz文件引起的安装中断,只需要到上面对应的路径里,删掉这个文件,重新执行安装命令即可:

/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"

2.若卡在了Cloning into...

由这里的龟速可断定卡住了,立马用Control + C中断命令执行,然后执行以下命令:

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

mkdir homebrew && cd homebrew

git clone git://mirrors.ustc.edu.cn/homebrew-core.git

三、Homebrew组成

主要由四个部分组成: brew,homebrew-core ,homebrew-cask,homebrew-bottles

它们对应的功能如下:

组成功能Homebrew源代码仓库homebrew-coreHomebrew 核心源homebrew-cask提供macos应用和大型二进制文件的安装homebrew-bottles预编译二进制软件包

四、Homebrew 基本用法有哪些

// 查询:

brew search 软件名

// 安装:

brew install 软件名

// 卸载:

brew uninstall 软件名

// 更新 Homebrew:

brew update

// 查看 Homebrew 配置信息:

brew config

注:使用官方脚本同样会遇到uninstall地址无法访问问题,可以替换为下面脚本:

/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall)"

参考链接:

macOS安装Homebrew教程从入门到入土_dlwlrma2022的博客-CSDN博客_homebrew安装教程Homebrew是个啥?怎么用?讲人话!macOS的包管理器,安装brew之后,仅需执行相应的命令,就能下载安装需要的软件包,可以省掉自己去下载、解压、拖拽(安装)等繁琐的步骤。比如nginx反向代理服务器等,打开终端执行以下命令即可安装:brew install 某某包名字这么牛的工具怎么安装?打开访达 - 实用工具 - 终端 输入以下命令方法一:brew官方安装/bin/bash -c "$(curl -fsSL https://raw.githubusercontenthttps://blog.csdn.net/m0_60845208/article/details/124246478

柚子快报激活码778899分享:MacOS安装Homebrew

http://yzkb.51969.com/

推荐链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: