国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Mac如何安裝Homebrew

這篇具有很好參考價(jià)值的文章主要介紹了Mac如何安裝Homebrew。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、簡(jiǎn)介

Homebrew是一款包管理工具,目前支持macOSLinux系統(tǒng)。主要有四個(gè)部分組成:brew、homebrew-core 、homebrew-cask、homebrew-bottles

名稱 說明
brew Homebrew源代碼倉(cāng)庫
homebrew-core Homebrew 核心源
homebrew-cask 提供 macOS 應(yīng)用和大型二進(jìn)制文件的安裝
homebrew-bottles 預(yù)編譯二進(jìn)制軟件包

mac怎么安裝homebrew,mac,macos

二、官方腳本下載安裝及配置環(huán)境變量

首先我們可以進(jìn)入官網(wǎng)地址獲取下載鏈接,如下:

mac怎么安裝homebrew,mac,macos

在安裝完成后如果遇到command not found: brew的錯(cuò)誤,一般是環(huán)境變量無效,這里則需要使用之前介紹使用過的echo $SHELL來確認(rèn)終端類型,如下

mac怎么安裝homebrew,mac,macos

以前每個(gè)新用戶的默認(rèn)shell是/bin/bash,那么這里我們需要配置文件為~/.bash_profile,從macOS Catalina(10.15.x) 版開始,Mac使用/bin/zsh作為默認(rèn)Shell,其對(duì)應(yīng)的配置文件為~/.zshrc

另外我們還需確定下我們電腦CPU的型號(hào),這里可以通過uname -m來查看,如下

mac怎么安裝homebrew,mac,macos

M1芯片ARM版Homebrew最終會(huì)被安裝在/opt/homebrew路徑下,而之前Intel芯片的Mac則會(huì)被安裝到/usr/local/Homebrew路徑下。

所以綜上所述,我們?cè)谂渲肏omebrew環(huán)境變量的時(shí)候,需要結(jié)合不同的情況來進(jìn)行相應(yīng)的配置,如下:

M1芯片

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
  • bash
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
eval "$(/opt/homebrew/bin/brew shellenv)"

Intel芯片

  • zsh
echo 'eval "$(/usr/local/Homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/usr/local/Homebrew/bin/brew shellenv)"
  • bash
echo 'eval "$(/usr/local/Homebrew/bin/brew shellenv)"' >> ~/.bash_profile
eval "$(/usr/local/Homebrew/bin/brew shellenv)"

三、GitHub加速

在使用官方腳本進(jìn)行下載安裝時(shí),經(jīng)常會(huì)遇到下面的錯(cuò)誤提示:

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

因?yàn)楣俜侥_本無法使用的原因是raw.githubusercontent.com訪問很不穩(wěn)定,這里我們可以采用寫入hosts的方式,可以一定程度解決GitHub資源無法訪問的問題。

3.1、Mac

這里我們可以打開/etc/hosts文件,在其中添加相關(guān)配置即可,具體操作可參考:

  • 主站:https://github.com/ineo6/hosts
  • 鏡像地址:https://gitee.com/ineo6/hosts

最后我們需要刷新緩存,如下

sudo killall -HUP mDNSResponder

3.2、Windows

另外如果是Windows環(huán)境,同理我們將上述文章中內(nèi)容追加到C:/windows/system32/drivers/etc/hosts文件中,刷新緩存即可。

ipconfig /flushdns

PS:如果覺得需要自己定時(shí)去上述hosts文件中的內(nèi)容太過于麻煩的話,這里推薦可使用通過SwitchHosts來自動(dòng)更新,操作很簡(jiǎn)單,支持跨平臺(tái),添加一條hosts規(guī)則并啟用,然后就可以按設(shè)置的時(shí)間間隔自動(dòng)與最新的hosts保持同步了。

四、鏡像腳本安裝

如果通過官方提供的方式無法成功安裝,這里推薦使用Homebrew的鏡像腳本來進(jìn)行安裝,這里比較推薦兩個(gè),首先是如下腳本:

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

該腳本用了中科大鏡像加速訪問,僅修改倉(cāng)庫地址部分,不會(huì)產(chǎn)生安全隱患。

關(guān)于中科大所提供的Homebrew鏡像服務(wù)

  • https://mirrors.ustc.edu.cn/help/brew.git.html?highlight=homebrew
  • https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git/

關(guān)于清華所提供的Homebrew鏡像服務(wù)

  • https://mirror.tuna.tsinghua.edu.cn/help/homebrew/

若出現(xiàn)Error: Checksum mismatch. 錯(cuò)誤,報(bào)錯(cuò)代碼如下

curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
Error: Checksum mismatch.
Expected: b065e5e3783954f3e65d8d3a6377ca51649bfcfa21b356b0dd70490f74c6bd86
Actual: e8a348fe5d5c2b966bab84052062f0317944122dea5fdfdc84ac6d0bd513c137
Archive: /Users/rocky/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í)行安裝命令即可。

如果上述命令執(zhí)行卡在如下信息處

==> Tapping homebrew/core
Cloning into ‘/opt/homebrew/Library/Taps/homebrew/homebrew-core’…

請(qǐng)Control+C中斷腳本執(zhí)行如下命令:

cd "$(brew --repo)/Library/Taps/"
mkdir homebrew && cd homebrew
git clone git://mirrors.ustc.edu.cn/homebrew-core.git

安裝cask 同樣也有安裝失敗或者卡住的問題,解決方法也是一樣:

cd "$(brew --repo)/Library/Taps/"
cd homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git

成功執(zhí)行之后繼續(xù)執(zhí)行安裝命令,最后看到如何命令就說明安裝成功了

==> Installation successful!

最后使用下面的命令進(jìn)行更新即可

brew update

如果遇到解決不了的問題,先卸載Homebrew再重新安裝,官方提供的卸載腳本如下:

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

當(dāng)然使用官方腳本同樣會(huì)遇到uninstall地址無法訪問問題,那么就可以使用下面腳本:

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

這里刪除不僅可以通過腳本進(jìn)行卸載刪除,還可以在文件夾中進(jìn)行刪除,如下

# 目錄替換為真實(shí)的brew位置
sudo rm -rf 目錄

另外在Mac電腦的終端中,還可以執(zhí)行open /opt/homebrew/打開文件夾界面進(jìn)行刪除。

PS:各個(gè)環(huán)境下Homebrew的安裝路徑:

  • Intel安裝目錄: /usr/local/Homebrew
  • m1 arm安裝目錄: /opt/homebrew
  • linux安裝目錄:/home/linuxbrew

第二種方法就更加的簡(jiǎn)便了,我們只需要把下面的腳本內(nèi)容復(fù)制到終端執(zhí)行即可

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

然后根據(jù)終端中出現(xiàn)的提示進(jìn)行選擇即可,如果后續(xù)需要卸載也是比較方便的,如下:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"

五、更換鏡像源

上述介紹到,Homebrew通常用來下載安裝軟件的,但它在下載軟件時(shí)非常慢。為了提升下載速度,需要更改Homebrew的安裝源,將其替換成國(guó)內(nèi)鏡像。

5.1、中科大

這里用由中科大負(fù)責(zé)托管維護(hù)的Homebrew鏡像為例。其中brew、homebrew-core是必備項(xiàng)目,homebrew-cask、homebrew-bottles按需設(shè)置??赏ㄟ^ brew config 命令可以查看相關(guān)配置信息。

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

brew update

另外如需設(shè)置bottles鏡像,還需要配置環(huán)境變量,這里配置文件的判斷上面已經(jīng)介紹過來,這里就不再贅述了,按照不同的情況選擇下面的其中一種配置即可。

# zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile
source ~/.zprofile

# bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile
source ~/.bash_profile

除了中科大的鏡像源外,我們還可以使用其他的鏡像源進(jìn)行配置

5.2、清華

# brew
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

brew update
# zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile
source ~/.zprofile

# bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile
source ~/.bash_profile

5.3、騰訊

# brew
git -C "$(brew --repo)" remote set-url origin https://mirrors.cloud.tencent.com/homebrew/brew.git
# homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.cloud.tencent.com/homebrew/homebrew-core.git
# homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.cloud.tencent.com/homebrew/homebrew-cask.git

brew update
# zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.cloud.tencent.com/homebrew-bottles/bottles' >> ~/.zprofile
source ~/.zprofile

# bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.cloud.tencent.com/homebrew-bottles/bottles' >> ~/.bash_profile
source ~/.bash_profile

5.4、北京外國(guó)語

# brew
git -C "$(brew --repo)" remote set-url origin https://mirrors.bfsu.edu.cn/git/homebrew/brew.git
# homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.bfsu.edu.cn/git/homebrew/homebrew-core.git
# homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.bfsu.edu.cn/git/homebrew/homebrew-cask.git

brew update
# zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.bfsu.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile
source ~/.zprofile

# bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.bfsu.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile
source ~/.bash_profile

5.5、阿里

# brew
git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# homebrew-cask
# 缺少

brew update
# zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zprofile
source ~/.zprofile

# bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

六、恢復(fù)默認(rèn)源

如果我們想要恢復(fù)Homebrew的默認(rèn)鏡像源也是非常的簡(jiǎn)單,其中brew、homebrew-core、homebrew-cask可通過執(zhí)行如下腳本命令進(jìn)行恢復(fù)

# brew
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
# homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
# homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update

其中homebrew-bottles配置只能手動(dòng)刪除,將~/.zprofile文件中的HOMEBREW_BOTTLE_DOMAIN=https://mirrors.xxx.com內(nèi)容刪除,并執(zhí)行source ~/.zprofile即可文章來源地址http://www.zghlxwxcb.cn/news/detail-859745.html

七、Homebrew常用命令

  • 查看版本
brew -v
  • 更新Homebrew
brew update
  • 查看安裝列表
brew list
  • 搜索、安裝、更新、卸載軟件,以git為例
# 搜索軟件
brew search git
?
# 安裝軟件
brew install git
?
# 更新軟件
brew upgrade git
?
# 卸載軟件
brew uninstall git
  • 查看需要更新的軟件
brew outdated
  • 清理舊版本
# 查看可清理的舊版本包,不執(zhí)行實(shí)際操作
brew cleanup -n
?
# 清理所有包的舊版本
brew cleanup
?
# 清理指定包的舊版本
brew cleanup git

到了這里,關(guān)于Mac如何安裝Homebrew的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • mac 安裝 Homebrew教程

    mac 安裝 Homebrew教程

    作為mac的用戶,如果你還沒安裝 Homebrew 那真的就太遺憾了,應(yīng)為其真的很好用,然后安裝 Homebrew 有時(shí)候有不是那么簡(jiǎn)單,會(huì)出現(xiàn)很多奇奇怪怪的錯(cuò)誤,如下是我本人第一次安裝就成功,其重要用的是 中科大的brew主體 ,使用這個(gè)只需要無腦點(diǎn)擊下一步即可,具體實(shí)現(xiàn)步驟如

    2024年02月11日
    瀏覽(24)
  • Mac系統(tǒng)HomeBrew安裝過程

    Mac系統(tǒng)HomeBrew安裝過程

    目錄 一、Homebrew是什么? 二、安裝環(huán)境 三、安裝步驟 四、確認(rèn)知否安裝成功 總結(jié) 前言 今天重裝系統(tǒng)了,記錄下安裝Brew的安裝過程。 Homebrew 是一個(gè)包管理器,用來在 macOS 安裝 Linux 工具包。 我的系統(tǒng)是macOS Monterey 12.6,完整的信息如下圖: 把下面命令復(fù)制粘貼到終端 /bin/z

    2024年01月17日
    瀏覽(48)
  • mac 安裝homebrew ,golang

    mac 安裝homebrew ,golang

    回車執(zhí)行指令后,根據(jù)提示操作。具體包括以下提示操作: 選擇下載鏡像。一般選擇中科大或者清華 確認(rèn)刪除舊版本 輸入開機(jī)密碼 安裝git【如果沒安裝會(huì)提示你,點(diǎn)擊安裝即可】 再次執(zhí)行 驗(yàn)證是否安裝成功 輸入 brew -v 安裝包下載地址為:https://go.dev/dl/。 如果打不開可以

    2024年02月08日
    瀏覽(21)
  • Mac Homebrew 安裝與卸載

    Mac Homebrew 安裝與卸載

    Homebrew 是一款Mac OS平臺(tái)下的軟件包管理工具,擁有安裝、卸載、更新、查看、搜索等很多實(shí)用的功能。簡(jiǎn)單的一條指令,就可以實(shí)現(xiàn)包管理,而不用你關(guān)心各種依賴和文件路徑的情況,十分方便快捷。 一、Homebrew 安裝與卸載 安裝方式一(推薦):(使用 科大源 進(jìn)行安裝) 安裝

    2024年02月05日
    瀏覽(23)
  • Mac ? 如何在MacOS上安裝pip軟件包

    Mac ? 如何在MacOS上安裝pip軟件包

    以 requests 工具包為例:

    2024年01月18日
    瀏覽(30)
  • Mac M1安裝homebrew步驟

    5.運(yùn)行brew -v 出現(xiàn)以下情況 輸入 6、再次輸入brew -v顯示如下,證明安裝成功 7、在終端使用brew install fig 命令安裝自動(dòng)補(bǔ)全工具,下載好回桌面點(diǎn)擊fig安裝,途中如果有問題就可以 brew uninstall fig,重新安裝。在保證網(wǎng)絡(luò)好的情況下安裝軟件。

    2024年02月08日
    瀏覽(26)
  • Mac如何將homebrew添加到系統(tǒng)路徑

    1.在終端下進(jìn)入路徑配置文件 2.輸入用戶密碼進(jìn)入文本,鍵盤按 i 進(jìn)入編輯模式(左下角會(huì)顯示INSERT狀態(tài)),配置環(huán)境變量: 3.Esc退出編輯模式,輸入**: 然后輸入 wq**,保存并退出 4.終端下輸入如下命令,更新環(huán)境變量 5.查看環(huán)境變量是否設(shè)置成功

    2024年02月16日
    瀏覽(27)
  • 使用Homebrew在Mac上安裝Git

    使用Homebrew在Mac上安裝Git

    僅針對(duì)第一次安裝使用Git 1.配置用戶名,用戶名,不推薦使用中文,最好使用拼音或者英文作為用戶名 2.配置郵箱? 如果公司并沒有加密,可以使用http拉取代碼,這一步可省略 出現(xiàn)上面這類數(shù)據(jù),說明公鑰生成成功 查看公鑰 ?然后錄登錄gitlab,進(jìn)入設(shè)置里,在ssh keys里添加秘鑰即可

    2024年02月11日
    瀏覽(27)
  • MAC:homebrew安裝nvm及node

    MAC:homebrew安裝nvm及node

    終端輸入: 安裝完成后會(huì)出現(xiàn)提示: You should create NVM\\\'s working directory if it doesn\\\'t exist: ? mkdir ~/.nvm Add the following to ~/.zshrc or your desired shell configuration file: ? export NVM_DIR=\\\"$HOME/.nvm\\\" ? [ -s \\\"/opt/homebrew/opt/nvm/nvm.sh\\\" ] . \\\"/opt/homebrew/opt/nvm/nvm.sh\\\"? # This loads nvm ? [ -s \\\"/opt/homebrew/opt/nvm/etc

    2024年02月12日
    瀏覽(19)
  • 【macOS 系列】如何在mac下安裝nvm實(shí)現(xiàn)多版本nodejs

    【macOS 系列】如何在mac下安裝nvm實(shí)現(xiàn)多版本nodejs

    注意:mac下用nvm。win下用nvm-windows 以下步驟都是在命令行工具下執(zhí)行: 1、安裝 2、刷新系統(tǒng)環(huán)境 3、驗(yàn)證是否安裝成功 4、使用和下載其他node版本 參考鏈接: https://github.com/nvm-sh/nvm 如何在window中使用: https://www.imqd.cn/user-nvm-window-manage-nodejs.html 在重啟終端后,又不能運(yùn)行nv

    2024年02月12日
    瀏覽(17)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包