首页 > 其他分享 >Homebrew

Homebrew

时间:2024-01-17 19:56:29浏览次数:22  
标签:git -- repo https homebrew brew Homebrew

1. 介绍

Homebrew 是一款包管理工具,目前支持 macOS 和 Linux 系统。主要有四个部分组成:brew、homebrew-core 、homebrew-cask、homebrew-bottles。

2. 安装

2.1 执行安装脚本

执行/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)",镜像选阿里巴巴,傻瓜式安装,30 分钟左右,安装完成。

2.2 验证安装成功

执行brew --version 验证是否安装成功。

2.3 更换下载源

2.3.1 更换 brew.git

git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git # 中科大
或
git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git # 阿里巴巴
或
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git # 清华大学


2.3.2 更换 homebrew-core.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git # 中科大
或
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git # 阿里巴巴
或
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git # 清华大学


2.3.3 更换 homebrew-cask.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git # 中科大
或
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git # 阿里巴巴
或
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git # 清华大学


2.3.4 更换 homebrew-bottles

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile # 阿里云
或
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile # 中科大
或
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile # 清华大学

source ~/.bash_profile


如果终端使用的是 zsh,就写入 zsh 的配置文件中。

2.3.5 更新软件包

执行brew update,如果可以更新成功,更换的源可用。

2.4 恢复默认源

某些情况下,可能我们使用的国内源挂掉了,就需要恢复默认源。

1. git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
2. git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
3. git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
4. 删除环境变量 HOMEBREW_BOTTLE_DOMAIN
5. source ~/.bash_profile
6. brew update

3. 意外处理

  1. 先执行brew doctor查看问题,按照指示对问题进行修复
  2. 执行brew update-reset 将 homebrew 还原到稳定版
  3. 执行brew update 更新软件包

4. 常用命令

4.1 安装软件

  • brew install node 默认安装最新版
  • brew install [email protected] 安装指定版本
  • brew switch node 16.0.0 切换版本

4.2 更新软件

  • brew upgrade name 更新安装过的软件 (如果不加软件名,就更新所有可以更新的软件)

4.3 卸载软件

  • brew uninstall node 卸载 node

4.4 服务相关

  • brew services list 获取 services 列表

  • brew services start/stop/restart serverName

  • brew services start mysql 启动 mysql 服务

  • brew services restart mysql 重启 mysql 服务

  • brew services stop mysql 停止 mysql 服务

4.5 其他常用命令

  • brew config 查看 brew 配置
  • brew info node 查看 node 安装信息
  • brew list 查看已安装软件
  • brew list --versions 查看已安装软件版本号
  • brew search node 搜索可用 node 相关软件
  • brew update brew 自身更新
  • brew cleanup 清除下载的缓存
  • brew doctor 诊断 brew,并给出修复命令

5. 卸载 Homebrew

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"

6. 参考

  1. Homebrew 国内如何自动安装(国内地址)(Mac & Linux)

标签:git,--,repo,https,homebrew,brew,Homebrew
From: https://www.cnblogs.com/cps666/p/17971041

相关文章

  • 安装Homebrew
    1.简介一款包管理工具,目前支持macOS和Linux系统。主要有四个部分组成:brew、homebrew-core、homebrew-cask、homebrew-bottles。2.安装1.执行/bin/zsh-c"$(curl-fsSLhttps://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)",镜像选阿里巴巴,30分钟左右,安装完成。2......
  • Homebrew学习(一)之初认识
    Homebrew学习(一)之初认识 HomebrewHomebrew是一款MacOS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,会自动下载相关依赖,十分方便便捷(缺失包管理器)Homebrew能干什么?......
  • Homebrew学习(二)之安装、卸载、更新
      安装请先看总结!!!!!1、网上的安装方法都是用curl,从官网找到命令复制到终端,然后回车,结果报错请求超时/usr/bin/ruby-e"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"然后自己试了一下这个链接  https://raw.githubusercontent.......
  • homebrew学习(三)之homebrew命令
      安装homebrew:/usr/bin/ruby-e"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"卸载homebrew:$cd`brew--prefix`$rm-rfCellar$brewprune$rm`gitls-files`$rm-rLibrary/HomebrewLibrary/A......
  • homebrew学习(四)之取消homebrew自动更新
      homebrew自动更新使用brewinstall/brewcaskinstall安装软件总是先updatingHomeBrew…,速度很慢取消homebrew自动更新方法一:使用命令行,但每次重启后需要重新执行命令exportHOMEBREW_NO_AUTO_UPDATE=true方法二:如果想要重启后设置依然生效,可以把上面这行加入到......
  • homebrew学习(五)之homebrew cask和homebrew services
      homebrewcask如果我想安装Chrome浏览器怎么办?试试下面的命令:brewinstallgoogle-chrome发现并不能安装,没有该软件。怎么办?好消息是一个叫做homebrew-cask的工具扩充了homebrew。Homebrewcask软件仓库,提供macOS应用和大型二进制文件安装brewinstallcaskro......
  • Homebrew学习(六)之替换及重置homebrew、Homebred Core、Homebrew cask默认源
      替换及重置homebrew默认源中科大源替换官方源://替换brew.git:cd"$(brew--repo)"gitremoteset-urloriginhttps://mirrors.ustc.edu.cn/brew.git//替换homebrew-core.git:cd"$(brew--repo)/Library/Taps/homebrew/homebrew-core"gitremoteset-url......
  • Homebrew 镜像源配置(清华)
    临时设置(运行下面这行命令)exportHOMEBREW_API_DOMAIN="Indexof/homebrew-bottles/api"&&exportHOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"&&exportHOMEBREW_BREW_GIT_REMOTE="https://mirr......
  • mac 下使用 brew 安装包报错 error: Cannot install under Rosetta 2 in ARM default
    mac下使用brew安装包报错error:CannotinstallunderRosetta2inARMdefaultprefix(/opt/homebrew)!TorerununderARMuse:arch-arm64brewinstall...Toinstallunderx86_64,installHomebrewinto/usr/local.解决办法:arch-arm64brewinstallxxx......
  • mac node 卸载 homebrew
    macnode卸载如果是通过source或者binaries方式安装Nodejs,需要手动删除Nodeexecutables和其他resources,另外就是使用Homebrew的方法、nvm方法。1.手动方法:需要按如下步骤卸载node+npm:从/usr/local/lib目录下删除全部node和node_modules之后,从/usr/loca......