homebrew的安装

前言:搞了半天不行,直接搜b站视频就解决了

https://www.bilibili.com/video/BV1E44y1r7uP?spm_id_from=333.337.search-card.all.click&vd_source=72045af31565236007a9c12952a316eb 主要是评论的文档

参考安装文档:
https://brew.idayer.com/guide/start/

参考:

  1. 设置使用中科大镜像
    HOMEBREW_CORE_GIT_REMOTE=https://mirrors.ustc.edu.cn/homebrew-core.git

  2. 安装homebrew
    /bin/bash -c “$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)”

  3. 添加 Homebrew 到 /Users/你的用户名/.zprofile 文件的 PATH 中,执行下面命令即可:
    echo 'eval “ ( / o p t / h o m e b r e w / b i n / b r e w s h e l l e n v ) " ′ > > / U s e r s / 你 的 用 户 名 / . z p r o f i l e e v a l " (/opt/homebrew/bin/brew shellenv)"' >> /Users/你的用户名/.zprofile eval " (/opt/homebrew/bin/brewshellenv)">>/Users//.zprofileeval"(/opt/homebrew/bin/brew shellenv)”

安装完成后,可以用brew doctor命令检测下是否有什么冲突的地方


正常操作踩的坑如下,由于我先使用下面的操作,上面的操作可能也需要用到下面的/etc/hosts的配置 or Xcode-select的下载

1、访问 HomeBrew 官网
homebrew的安装_第1张图片

复制 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 输入到终端
此时会报错 Could not resolve host: raw.githubusercontent.com
是因为找不到 raw.githubusercontent.com
2、找到 raw.githubusercontent.com 对应的ip地址
https://ipaddress.com/website/raw.githubusercontent.com直接在这里搜索

复制ipv4的任意一个地址
终端:vim /etc/hosts 将 185.199.108.133 raw.githubusercontent.com 添加到最后一行,如果不能编辑就到文件中修改hosts的文件权限改成读与写,然后:wq!保存
3、 重复步骤1终端输入,需要密码就输入密码,其他回车,会发现报错了 Xcode-select: error: invalid developer directory ‘/Library/Developer/CommandLineTools’
4、此时需要安装 Xcode-select,输入xcode-select --install
homebrew的安装_第2张图片
我的报错了,所以选择第二种安装方法离线安装

Apple 家官网:https://developer.apple.com/download/more/
以 Apple ID 登录
在搜索框搜索 Command Line Tools
打开你 macOS 上的 XCode,检查其版本号
下载对应版本的 Command Line Tools 镜像(*.dmg)
从镜像里手工安装

5、github.com访问错误
fatal: unable to access 'https://github.com/Homebrew/brew/': Could not resolve host: github.com Failed during: git fetch --force origin
同步骤2的方法将140.82.113.4 github.com添加到 /etc/hosts最后一行

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

fatal: cannot change to ‘/opt/homebrew/Library/Taps/homebrew/homebrew-cask’: No such file or directory

你可能感兴趣的:(homebrew)