大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全家桶1年46,售后保障稳定

Homebrew 是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。
一、Homebrew 安装与卸载
-
安装方式一
(推荐):(使用 科大源 进行安装)- 安装
$ /bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"- 卸载
$ /bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/uninstall.sh)"- 如果报错
Error: No similarly named formulae found.,则更换一下homebrew-core文件即可,如果git clone的方式慢,也可以直接打开链接进行下载,将下载的文件夹改成homebrew-core替换掉之前的homebrew-core文件即可。
$ cd /usr/local/Homebrew/Library/Taps/homebrew/ $ rm -rf homebrew-core $ git clone https://github.com/Homebrew/homebrew-core.git -
安装方式二:(完全纯官方安装,但是需要配置
host,githubusercontent国内访问不了)$ /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 reset by peer -
卸载
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"卸载过程中根据提示进行操作
dengzemiaodeMacBook-Pro:~ dengzemiao$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)" Warning: This script will remove: /Users/dengzemiao/Library/Caches/Homebrew/ /usr/local/Caskroom/ /usr/local/Cellar/ /usr/local/bin/brew -> /usr/local/bin/brew Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] ......
二、Homebrew 使用
-
安装包
$ brew install 包名示例:
$ brew install node -
卸载包
$ brew uninstall 包名示例:
$ brew uninstall node -
查询可用包
$ brew search 包名 -
查看已安装包列表
$ brew list -
查看任意包信息
$ brew info 包名 -
查看版本
$ brew -v -
更新 Homebrew
$ brew update -
Homebrew 帮助信息
$ brew -h
三、Homebrew 常见问题
-
注意事项:在
Mac OS X 10.11系统以后,/usr/local/等系统目录下的文件读写是需要系统root权限的,以往的Homebrew安装如果没有指定安装路径,会默认安装在这些需要系统root用户读写权限的目录下,导致有些指令需要添加sudo前缀来执行,比如升级Homebrew需要:$ sudo brew update -
报错
echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.bash_profiledengzemiaodeMacBook-Pro:~ dengzemiao$ brew search nginx Warning: Error searching on GitHub: GitHub Bad credentials:The GitHub credentials in the macOS keychain may be invalid. Clear them with: printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase Or create a personal access token: https://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.bash_profile ==> Formulae nginx解决方式:
1、点击错误中的链接,就会打开
github页面,进入页面之后直接滚到底部点击Generate token按钮,然后拷贝得到的token:https://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew

2、打开命令行,输入下面命令,回车之后就行了,然后就正常使用:
$ export HOMEBREW_GITHUB_API_TOKEN=填入你刚才得到的Token
例如:
$ export HOMEBREW_GITHUB_API_TOKEN=465832bc2dd057a2c556f...
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/219090.html原文链接:https://javaforall.net
