您的位置 首页 > 腾讯云社区

Homebrew 入门---zucchiniy

homebrew 安装

使用下面的命令进行安装,但是需要先安装 curl :

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"常用命令搜索brew search mysql查询brew info mysql

主要看具体的信息,比如目前的版本,依赖,安装后注意事项等

更新brew update

这会更新 Homebrew 自己,并且使得接下来的两个操作有意义

检查过时brew outdated

这回列出所有安装的软件里可以升级的那些

升级brew upgrade

升级所有可以升级的软件们

清理brew cleanup

清理不需要的版本极其安装包缓存

后台启用服务

brew services 命令是用来管理 Mac 系统中后台服务的,比如在 Mac 上安装了 MySQL ,当我希望将这个变成一个后台服务启动的时候,可以使用,有点像 Linux 下的 service 和 systemctl 两个命令。

具体的使用命令也非常简单:

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 # 清除已卸载应用的无用的配置配置国内镜像

使用了一段时间的 Homebrew 之后,发现网络波动有点大,好多时间都是更新10多分钟,所以就想到了国内镜像问题。

其实无论是什么内容,只要是需要更新的,就有两个优先选择的,一个是清华源,一个是科大源,这两个是最好用的镜像了。

另外一个就是 NPM 的阿里源,这三个源都非常好用。

对于我的使用,主要是两个,一个是 formula 索引,另一个是 bottles 。

formula 更新使用

cd "$(brew --repo)" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git brew update

bottles 镜像则需要配置到环境变量中,我使用的是 zsh shell 所以配置到 .zshrc 文件中

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

如果你想临时使用的话,则需要在终端中输入 export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles ,当然如果你使用的是 bash shell 则可以将其配置到 .bash_profile 或者 .bashrc 文件中。

更新报错

更新的时候,发现 homebrew 安装的时候,会报错 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out ,测试了一下,发现是因为 curl 这个命令有问题了,使用 homebrew 重新安装一下就可以。 brew reinstall curl。

---来自腾讯云社区的---zucchiniy

关于作者: 瞎采新闻

这里可以显示个人介绍!这里可以显示个人介绍!

热门文章

留言与评论(共有 0 条评论)
   
验证码: