Mac安裝homebrew,並替換使用清華映象源

2022-09-11 02:39:17 字數 2284 閱讀 3897

mac os moj**e 10.14.5

1.在~/.bash_profile設定路徑

if [[ "$(uname -s)" == "linux" ]]; then brew_type="linuxbrew"; else brew_type="homebrew"; fi

export homebrew_brew_git_remote=""

export homebrew_core_git_remote=""

export homebrew_bottle_domain=""

在terminal執行source ~/.bash_profile命令,使路徑配置生效。

source ~/.bash_profile

git clone --depth=1  brew-install

/bin/bash brew-install/install.sh

rm -rf brew-install

輸入開機密碼繼續安裝

==> checking forsudoaccess (which may request your password).

password:

brew -v測試homebrew是否安裝成功

brew -v

homebrew 3.1.2-2-g8853fb6

homebrew/homebrew-core (git revision 91c19159ac; last commit 2021-04-15)

homebrew/homebrew-cask (git revision 749fbfa712; last commit 2021-04-15)

表明安裝成功

3.替換現有倉庫上游

替換 brew 程式本身的源

git -c "$(brew --repo)" remote set-url origin

自動設定 macos 系統上的 homebrew

brew_taps="$(brew tap)"

for tap in core cask; do

if echo "$brew_taps" | grep -qe "^homebrew/$\$"; then

# 將已有 tap 的上游設定為本映象並設定 auto update

# 注:原 auto update 只針對託管在 github 上的上游有效

git -c "$(brew --repo homebrew/$)" remote set-url origin

git -c "$(brew --repo homebrew/$)" config homebrew.forceautoupdate true

else # 在 tap 缺失時自動安裝(如不需要請刪除此行和下面一行)

brew tap --force-auto-update homebrew/$

fidone

更換上游後需重新設定 git 倉庫 head

brew update-reset

branch 'master' set up to track remote branch 'master' from 'origin'.

reset branch 'master'

your branch is up to date with 'origin/master'.

4.嘗試安裝npm

brew install node

==> downloading

==> downloading from

curl: (22) the requested url returned error: 404 not found

trying a mirror...

==> downloading

==> downloading from

curl: (22) the requested url returned error: 404

error: failed to download resource "brotli"

download failed:

Mac安裝Homebrew並更換國內映象源

usr bin ruby e curl fssl 或者 bin bash c curl fssl 最近找到的,國內可以直接用這個,非常快 bin bash c curl fssl homebrew類似於redhat系列linux系統裡面的yum命令和ubuntu系列的apt命令。homebrew有三...

Mac 安裝home brew出錯

mark翻車經過 鹿晗公開戀情了。hhhh跟我沒有關係,老薛got7 好!安裝homebrew的時候翻車了。原因大概是不懂mac得.git config的許可權,強行回憶了一波作業系統裡許可權管理的問題,解決了。翻車現場大概是這樣 在terminal裡輸出 usr bin ruby e curl f...

Mac終端安裝Homebrew

homebrew,homebrew簡稱brew,是mac osx上的軟體包管理工具,能在mac中方便的安裝軟體或者解除安裝軟體。1.開啟mac的終端 2.輸入安裝命令 ruby e curl fssl 3.執行上述命令後會提示輸入系統密碼 輸入如下命令進行解除安裝 複製內容到剪貼簿 ruby e c...