mac下homebrew的安裝更新


homebrew安裝

安裝

已廢棄

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

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

 

git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

 

brew doctor

 

國內鏡像

https://www.cnblogs.com/beyondmch/articles/8331478.html

https://www.jianshu.com/p/dee2e61dcb70

 

pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

 

https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git

 

設置國外鏡像

git -C "/usr/local/Homebrew" remote set-url origin https://github.com/Homebrew/brew

git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" remote set-url origin https://github.com/Homebrew/homebrew-core

 

 

 

 

兩種方式來解決:

一、直接關閉brew執行命令時的自動更新

# 1. 編輯配置文件

vim ~/.bash_profile

 

# 2. 文件內新增一行

export HOMEBREW_NO_AUTO_UPDATE=true

 

# 3. 重新加載配置文件

source ~/.bash_profile

二、替換brew

cd "$(brew --repo)"

git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

 

#替換homebrew-core.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

brew update

# 備用地址-1

cd "$(brew --repo)"

git remote set-url origin https://git.coding.net/homebrew/homebrew.git

brew update

# 備用地址-2

cd "$(brew --repo)"

git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git

brew update

PS:官方默認信息

# 1. 重置brew.git

cd "$(brew --repo)"

git remote set-url origin https://github.com/Homebrew/brew.git

 

# 2. 重置homebrew-core.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://github.com/Homebrew/homebrew-core.git

 

 

阿里雲鏡像

1. 替換brew.git 倉庫地址:

 



cd "$(brew --repo)"


git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

還原

 



cd "$(brew --repo)"


git remote set-url origin https://github.com/Homebrew/brew.git

2. 替換homebrew-core.git 倉庫地址:

 



cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"


git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

還原

 

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"


git remote set-url origin https://github.com/Homebrew/homebrew-core.git

3. 替換homebrew-bottles 訪問地址

這個步驟跟你的 macOS 系統使用的 shell 版本有關系,先來查看當前使用的 shell 版本



echo $SHELL


/bin/zsh

3.1 zsh替換成阿里巴巴的 homebrew-bottles 訪問地址:

 



echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc


source ~/.zshrc

還原

 


vi ~/.zshrc


# 然后,刪除 HOMEBREW_BOTTLE_DOMAIN 這一行配置

source ~/.zshrc

3.2 bash替換成阿里巴巴的 homebrew-bottles 訪問地址:

 


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

source ~/.bash_profile

還原



vi ~/.bash_profile

# 然后,刪除 HOMEBREW_BOTTLE_DOMAIN 這一行配置

source ~/.bash_profile

 

 

Homebrew 更新命令

https://www.onlyling.com/archives/509

 

 

更新 Homebrew 自己

brew update

查看哪些安裝包需要更新

brew outdated

更新安裝包

brew upgrade   # 更新所有的包

brew upgrade $FORMULA   # 更新指定的包

清理舊版本

brew cleanup   # 清理所有包的舊版本

brew cleanup $FORMULA   # 清理指定包的舊版本

brew cleanup -n   # 查看可清理的舊版本包,不執行實際操作

鎖定不想更新的包

brew pin $FORMULA   # 鎖定某個包

brew unpin $FORMULA    # 取消鎖定

查看安裝包的相關信息

brew info $FORMULA   # 顯示某個包的信息

brew info   # 顯示安裝了包數量,文件數量,和總占用空間

brew deps --installed --tree   # 查看已安裝的包的依賴,樹形顯示

其他

列出已安裝包

brew list

刪除

brew rm $FORMULA   # 刪除某個包

brew uninstall --force $FORMULA   # 刪除所有版本


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM