美文网首页
Homebrew 入门到入门(Mac)

Homebrew 入门到入门(Mac)

作者: 刘_小_二 | 来源:发表于2020-06-19 11:03 被阅读0次

Homebrew 入门到入门(Mac)

官方网站:

http://mxcl.github.com/homebrew/

HomeBrew 安装

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

若直接输入命令后,发现报错如下

fatal: unable to access 'https://github.com/Homebrew/brew/': Could not resolve host: github.com
Failed during: git fetch origin master:refs/remotes/origin/master --tags --force

解决方法:

1.首先ping github.com:

PING github.com (52.74.223.119): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

2.将"52.74.223.119 http://github.com"填入host文件中

3.关闭并重新打开终端

4.重新输入安装命令

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

Homebrew安装成功后,会自动创建目录 /usr/local/Cellar 来存放Homebrew安装到程序。

查看brew镜像源

git -C "$(brew --repo)" remote -v

查看homebrew-core镜像源

git -C "$(brew --repo homebrew/core)" remote -v

查看homebrew-cask镜像源(需要安装后才能查看)

git -C "$(brew --repo homebrew/cask)" remote -v

修改brew镜像源

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

更新

brew update

附上恢复源的地址

git -C "(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git 

git -C "(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update

坑1:homebrew/core 和 homebrew/cask 文件缺失

Homebrew常用命令

1.配置文件目录

/Library/LaunchDaemons # 开机自启,需要sudo
~/Library/LaunchAgents # 用户登录后自启

2.相关服务命令

brew services list  # 查看使用brew安装的服务列表
brew services run formula|--all  # 启动服务(仅启动不注册)
brew services start formula|--all  # 启动服务,并注册
brew services stop formula|--all   # 停止服务,并取消注册
brew services restart formula|--all  # 重启服务,并注册
brew services cleanup  # 清除已卸载应用的无用的配置

3.命令实例

查看brew的帮助
brew –help

安装软件
brew install git

卸载软件
brew uninstall git

搜索软件
brew search git

显示已经安装软件列表
brew list

更新软件,把所有的Formula目录更新,并且会对本机已经安装并有更新的软件用*标明。
brew update

更新某具体软件
brew upgrade git

查看软件信息
brew [info | home] [FORMULA...]

删除程序,和upgrade一样,单个软件删除和所有程序老版删除。
brew cleanup git 
brew cleanup

查看那些已安装的程序需要更新
brew outdated
brew list   —列出已安装的软件

brew update   —更新Homebrew

brew home  *—用浏览器打开

brew info   *—显示软件内容信息

brew deps * — 显示包依赖

brew server *  —启动web服务器,可以通过浏览器访问http://localhost:4567/ 来同网页来管理包

brew -h brew   —帮助

相关文章

网友评论

      本文标题:Homebrew 入门到入门(Mac)

      本文链接:https://www.haomeiwen.com/subject/iikvxktx.html