Homebrew , is a package management tool that currently supports , Mac OS , and , linux , systems.
It is mainly composed of four parts: brew, homebrew core, homebrew cask and homebrew bottles.
name | explain |
---|---|
brew | Homebrew source code warehouse |
homebrew-core | Homebrew core source |
homebrew-cask | Provide installation of macOS applications and large binary files |
homebrew-bottles | Precompiled binary package |
This article mainly introduces how to install Homebrew and how to speed up access, and popularize some necessary knowledge by the way.
1. Script description
Homebrew default installation script:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Copy code
If you encounter the following prompt after waiting for a period of time, it means that you cannot access the official script address:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out Copy code
Use the following script:
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)" Copy code
The above script uses the image of China University of science and technology to speed up access.
2. Execute the order
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"
If the following information is stuck during command execution:
==> Tapping homebrew/core Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
Please , Command + C , interrupt the script and execute the following commands:
cd "$(brew --repo)/Library/Taps/" mkdir homebrew && cd homebrew git clone git://mirrors.ustc.edu.cn/homebrew-core.git
After successful execution, continue to execute the previous installation command.
Finally, I see = = > installation successful! The installation is successful.
Last execution:
brew update
cask # also has the problem of slow downloading for the first time. The solution is roughly the same as above:
cd "$(brew --repo)/Library/Taps/" cd homebrew git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
3. Uninstall Homebrew
If you use the official script, you will also encounter the problem that the "uninstall" address cannot be accessed. You can replace it with the following script:
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall)"
4. Set image
brew and homebrew/core are required items. homebrew/cask and homebrew/bottles are set as required.
View the configuration information through the brew config command.
4.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 # Long term replacement of homebrew pots echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile
Note that pots can be set temporarily. Execute the following command on the terminal:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
4.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 # Long term replacement of homebrew pots echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile
4.3 recovery
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
The homebrew bots configuration can only be deleted manually, and ~ / bash_ Homebrew in profile file_ BOTTLE_ DOMAIN= https://mirrors.xxx.com Delete the content and execute source ~ / bash_profile.
5. Others
5.1 cask
At present, # cask # reads the software source from # GitHub # while # GitHub Api # restricts anonymous access. If it is used frequently, you can apply for # Api Token, and then configure # homebrew in the environment variable_ GITHUB_ API_ TOKEN.
Yes bash_ Append to profile #:
export HOMEBREW_GITHUB_API_TOKEN=yourtoken
Note: because # cask # is based on # GitHub download software, it cannot be accelerated at present.
6. Summary
In the previous process, we point the addresses of "brew" and "homebrew core" to the image of China University of science and technology.
The principle is to modify the "install" script and preset the image address in it.
#!/usr/bin/ruby # This script installs to /usr/local only. To install elsewhere (which is # unsupported) you can untar https://github.com/Homebrew/brew/tarball/master # anywhere you like. HOMEBREW_PREFIX = "/usr/local".freeze HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze HOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freeze # Brew is replaced here_ REPO BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze
The last imperfection is that we can only preset the "brew" image, but we can't find a better way to preset the "git" addresses of "homebrew core" and "homebrew cask".
Author: ineo6
Link: https://juejin.im/post/6844903988559773709
Source: Nuggets
The copyright belongs to the author. For commercial reprint, please contact the author for authorization. For non-commercial reprint, please indicate the source.