Mac 下 brew 切換爲國內源,安裝 sshfs

簡介

Homebrew 是一款自由及開放源代碼的軟件包管理系統,用以簡化 macOS 和 linux 系統上的軟件安裝過程。它擁有安裝、卸載、更新、查看、搜索等很多實用的功能,通過簡單的一條指令,就可以實現包管理,十分方便快捷。

Homebrew 主要有四個部分組成: brewhomebrew-corehomebrew-bottleshomebrew-cask

名稱 說明
brew Homebrew 源代碼倉庫
homebrew-core Homebrew 核心軟件倉庫
homebrew-bottles Homebrew 預編譯二進制軟件包
homebrew-cask 提供 macOS 應用和大型二進制文件

替換爲阿里源

# 查看 brew.git 當前源
$ cd "$(brew --repo)" && git remote -v
origin    https://github.com/Homebrew/brew.git (fetch)
origin    https://github.com/Homebrew/brew.git (push)

# 查看 homebrew-core.git 當前源
$ cd "$(brew --repo homebrew/core)" && git remote -v
origin    https://github.com/Homebrew/homebrew-core.git (fetch)
origin    https://github.com/Homebrew/homebrew-core.git (push)

# 修改 brew.git 爲阿里源
$ git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 修改 homebrew-core.git 爲阿里源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# zsh 替換 brew bintray 鏡像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# bash 替換 brew bintray 鏡像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 刷新源
$ brew update

替換爲清華源

# 替換各個源
$ 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

# zsh 替換 brew bintray 鏡像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# bash 替換 brew bintray 鏡像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 刷新源
$ brew update

替換爲中科大源

# 替換各個源
$ 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

# zsh 替換 brew bintray 鏡像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# bash 替換 brew bintray 鏡像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 刷新源
$ brew update

重置爲官方源

# 重置 brew.git 爲官方源
$ git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

# 重置 homebrew-core.git 爲官方源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

# 重置 homebrew-cask.git 爲官方源
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask

# zsh 註釋掉 HOMEBREW_BOTTLE_DOMAIN 配置
$ vi ~/.zshrc
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx

# bash 註釋掉 HOMEBREW_BOTTLE_DOMAIN 配置
$ vi ~/.bash_profile
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx

# 刷新源
$ brew update

安裝 sshfs

卸載 sshfs macfuse osxfuse

$  brew uninstall macfuse
$  brew uninstall osxfuse
Error: Cask 'osxfuse' is not installed.
$  brew uninstall sshfs
Error: No such keg: /usr/local/Cellar/sshfs

卸載不掉就不需要管了。

安裝 macfuse:

$  brew install --cask macfuse
Running `brew update --auto-update`...
🍺  macfuse was successfully installed!

安裝sshfs-mac

$  brew install gromgit/fuse/sshfs-mac
Running `brew update --auto-update`...
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/glib-2.72.3.monterey.bottle.tar.gz
curl: (22) The requested URL returned error: 404
Already downloaded: /Users/smallsoup/Library/Caches/Homebrew/downloads/fcf96695d6c08464e1b562da3bfe8adc42b6ca76e068f086e7307bceeebfac0e--glib--2.72.3.monterey.bottle.tar.gz
#......
Error: No such file or directory @ rb_sysopen - /Users/smallsoup/Library/Caches/Homebrew/downloads/9b06ea2ff80ab1e5bb45d58488c97d8de11b891a26b47834ca8ec51485de87fb--glib-2.72.3.monterey.bottle.tar.gz

安裝報錯:No such file or directory xxxx

查看這個目錄發現glib--2.72.3.monterey.bottle.tar.gz存在,但前綴和報錯的不一樣,所以拷貝一份:

$ ll /Users/smallsoup/Library/Caches/Homebrew/downloads/
fcf96695d6c08464e1b562da3bfe8adc42b6ca76e068f086e7307bceeebfac0e--glib--2.72.3.monterey.bottle.tar.gz

$ mkdir -p /Users/smallsoup/Library/Caches/Homebrew/downloads/
$ cp /Users/smallsoup/Library/Caches/Homebrew/downloads/fcf96695d6c08464e1b562da3bfe8adc42b6ca76e068f086e7307bceeebfac0e--glib--2.72.3.monterey.bottle.tar.gz /Users/smallsoup/Library/Caches/Homebrew/downloads/9b06ea2ff80ab1e5bb45d58488c97d8de11b891a26b47834ca8ec51485de87fb--glib-2.72.3.monterey.bottle.tar.gz

再次安裝sshfs-mac,即可成功:

$  brew install gromgit/fuse/sshfs-mac

brew link爲您手動執行的安裝創建符號鏈接Cellar。這使您可以靈活地自行安裝多個版本的軟件,下面創建sshfs-mac的符號鏈接:

$  brew link --overwrite sshfs-mac
Warning: Already linked: /usr/local/Cellar/sshfs-mac/2.10_1
To relink, run:
  brew unlink sshfs-mac && brew link sshfs-mac

驗證sshfs是否安裝成功,查看版本:

$  sshfs -V
SSHFS version 2.10
FUSE library version: 2.9.9
fuse: no mount point

本文由mdnice多平臺發佈

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章