Homebrew 是什么Homebrew是 mac的包管理器,僅需執(zhí)行相應(yīng)的命令,就能下載安裝需要的軟件包,可以省掉自己去下載、解壓、拖拽(安裝)等繁瑣的步驟。 比如安裝服務(wù)器 nginx,打開終端執(zhí)行以下命令即可安裝: brew install nginx
Homebrew 怎么安裝方法一:brew官網(wǎng)的安裝腳本執(zhí)行命令: /bin/bash -c "$(curl -fsSL https://raw./Homebrew/install/master/install.sh)" 這時(shí)很可能會(huì)出現(xiàn)一個(gè)問題: 要么下載極其龜速,要么直接出現(xiàn)如下提示 curl: (7) Failed to connect to raw. port 443: Connection refused
此時(shí)需要換一種科學(xué)高效的安裝方法,即方法二。 方法二:brew 鏡像安裝腳本(親測最快速最有效)/usr/bin/ruby -e "$(curl -fsSL https://cdn./gh/ineo6/homebrew-install/install)"
注:注意這里的速度,幾百kib/s或幾m/s才是正常的。若只有幾kib/s,通常為無效的安裝方法,一般加載了百分之幾十后就會(huì)報(bào)錯(cuò)。 Homebrew 安裝時(shí)如何避坑1.若出現(xiàn) Error: Checksum mismatch.報(bào)錯(cuò)代碼如下: curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 Error: Checksum mismatch. Expected: b065e5e3783954f3e65d8d3a6377ca51649bfcfa21b356b0dd70490f74c6bd86 Actual: e8a348fe5d5c2b966bab84052062f0317944122dea5fdfdc84ac6d0bd513c137 Archive: /Users/joyce/Library/Caches/Homebrew/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz To retry an incomplete download, remove the file above. Error: Failed to install Homebrew Portable Ruby (and your system version is too old)! Failed during: /usr/local/bin/brew update --force 這里是由Homebrew目錄下的portable-ruby-2.6.3_2.yosemite.bottle.tar.gz文件引起的安裝中斷,只需要到上面對(duì)應(yīng)的路徑里,刪掉這個(gè)文件,重新執(zhí)行安裝命令即可: /usr/bin/ruby -e "$(curl -fsSL https://cdn./gh/ineo6/homebrew-install/install)" 2.若卡在了Cloning into...
cd "$(brew --repo)/Library/Taps/" mkdir homebrew && cd homebrew git clone git://mirrors.ustc.edu.cn/homebrew-core.git 執(zhí)行后可看到:
注:最后出現(xiàn) Installation successful! 或者 Checking out files: 100% (5392/5392), done. 說明安裝成功。 Homebrew安裝完為何需要配置前面已經(jīng)提到,Homebrew通常用來下載軟件的,但它在安裝軟件時(shí)非常慢。為了提升安裝速度,需要更改 Homebrew 的安裝源,將其替換成國內(nèi)鏡像。 這里用的是由中科大負(fù)責(zé)托管維護(hù)的 Homebrew 鏡像。其中,前兩個(gè)為必須配置的項(xiàng)目,后兩個(gè)可按需配置。 1.必備設(shè)置
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 2.按需設(shè)置
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
首先要先區(qū)分你的mac用哪種終端工具,如果是 bash,則執(zhí)行: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile 若是 zsh,則執(zhí)行: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc 注:Homebrew 主要由四個(gè)部分組成: brew、homebrew-core 、homebrew-cask、homebrew-bottles,它們對(duì)應(yīng)的功能如下:
Homebrew 基本用法有哪些// 查詢: brew search 軟件名 // 安裝: brew install 軟件名 // 卸載: brew uninstall 軟件名 // 更新 Homebrew: brew update // 查看 Homebrew 配置信息: brew config 注:使用官方腳本同樣會(huì)遇到uninstall地址無法訪問問題,可以替換為下面腳本: /usr/bin/ruby -e "$(curl -fsSL https://cdn./gh/ineo6/homebrew-install/uninstall)" 參考文章寫在最后在此之前試過了好幾種安裝方法,比如下載一個(gè) brew_install.rb的文件,然后執(zhí)行命令ruby brew_install.rb,一開始行得通,但下載到中途就會(huì)報(bào)錯(cuò),而且出錯(cuò)的方法不一,也嘗試過好幾種相應(yīng)的解決方法,最終都夭折了,只有這個(gè)鏡像安裝才能成功,而且下載速度非??臁?br>
|
|