The tutorial of replacing image and installing homebrew in MAC

Time:2021-7-7

Homebrew is a package management tool, which supports Mac OS and Linux system. It consists of four parts: brew, homebrew core, homebrew cask and homebrew robots.

Homebrew official default installation script:

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

If you meet the following prompt after waiting for some time, you cannot access the official script address:

  • curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out

Please follow the steps in the “installation instructions” below.

Installation instructions

1. Install homebrew core and homebrew cask

Create and enter the installation directory:

  • cd /usr/local/
  • mkdir -p Homebrew/Library/Taps && cd Homebrew/Library/Taps

Install the homebrew core and homebrew cask of the image source of CUHK respectively

  • HOMEBREW_CORE_GIT_REMOTE=https://mirrors.ustc.edu.cn/homebrew-core.git
  • git clone git://mirrors.ustc.edu.cn/homebrew-core.git
  • git clone https://mirrors.ustc.edu.cn/homebrew-cask.git

2. Install homebrew:

  • /bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

Finally, I see==> Installation successful!The installation is successful.

Last update:

  • brew update

supplement

1. Reference documents

  • By: sword in the lake
  • Tsinghua University open source software mirror station

  • China University of science and technology

2. How to uninstall homebrew

Using the official script will also encounter problemsuninstallIf the address cannot be accessed, you can use the following script:

  • /bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall.sh)"

3. Set the image

Brew and homebrew / core are required items, and homebrew / cask and homebrew / robots are set on demand. Through the brew config command, you can view the relevant configuration information.

3.1 China University of science and technology
  • git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
  • git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
  • git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
  • brew update
3.2 source of Tsinghua University
  • git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
  • git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
  • git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
  • brew update
3.3 restore default source
  • 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