配置homebrew

1,049 阅读1分钟

Homebrew配置

Homebrew是mac包管理器,本次环境配置是ARM版本的Homebrew。 在mac m1中安装

安装流程

  1. 执行官方给的路径
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

当出现

==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/leanderluo/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh

说明安装成功 2. 执行日志中的脚本

    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/leanderluo/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
  1. 验证执行
brew -v

若出现类似内容:

Homebrew 3.5.4
Homebrew/homebrew-core (git revision 517ea1d5ce4; last commit 2022-07-13)

说明成功

出现的问题及解决方法

问题1

curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 67 ms: Connection refused

由于是重装了系统,未初始化xcode的环境。有两种解决方案: 1. 安装switchhosts,随时对更改的github地址进行访问。 2. 更改系统文件中hosts文件。 本次采用的是第二种方案,步骤如下 1. 访问https://ipaddress.com/,查询raw.githubusercontent.com对应的地址 2. 编辑hosts。 sudo vim /etc/hosts 添加,并保存 [查询的ip地址] raw.githubusercontent.com

问题2

fatal: unable to access 'https://github.com/Homebrew/brew/': HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
Failed during: git fetch --force origin

解决:

git config --global --unset http.proxy //无需用这一条也能解决
git config --global --unset https.proxy