博客 / 詳情

返回

開發常用軟件鏡像加速收集

pypi

臨時使用:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

長期使用:

升級 pip 到最新的版本 (>=10.0.0) 後進行配置:

pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

如果您到 pip 默認源的網絡連接較差,臨時使用本鏡像站來升級 pip:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U

可用源地址

  • 阿里雲 - https://mirrors.aliyun.com/py...
  • 清華大學 - https://pypi.tuna.tsinghua.ed...
  • 中國科學技術大學 - https://pypi.mirrors.ustc.edu...
  • 豆瓣 - https://pypi.douban.com/simple

nvm

臨時使用:

export NVM_NODEJS_ORG_MIRROR="https://npm.taobao.org/mirrors/node/"

長期使用:

echo 'export NVM_NODEJS_ORG_MIRROR="https://npm.taobao.org/mirrors/node/"' >> ~/.bashrc

Ruby Gems

gem

# 添加 TUNA 源並移除默認源
gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
# 列出已有源
gem sources -l
# 應該只有一個

Gemfile 和 Bundler 的項目

bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems/

可用源地址

  • 清華 - https://mirrors.tuna.tsinghua...
  • 中科大 - https://mirrors.ustc.edu.cn/r...
  • ruby-china - https://gems.ruby-china.com/

CocoaPods

舊版使用方式:

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

新版的CocoaPods不允許用pod repo add直接添加master庫了,但是依然可以通過下面方式:

$ cd ~/.cocoapods/repos 
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

最後在Podfile第一行加上:

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

可用源地址

  • 清華 - https://mirrors.tuna.tsinghua...

Flutter

Flutter是一款跨平台的移動應用開發框架,由Google開源。用Flutter開發的應用可以直接編譯成ARM代碼運行在AndroidiOS系統上。

Flutter安裝時需要從Google Storage 下載文件,如您的網絡訪問Google受阻,需要使用鏡像。

臨時使用:

export FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter"

長期使用:

echo 'export FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter"' >> ~/.bashrc

此外Flutter開發中還需要用到Dart語言的包管理器Pub,其鏡像使用方法參見Pub 鏡像安裝幫助。

Pub

PubDart官方的包管理器。跨平台的前端應開發框架Flutter也基於Dart,並且可以使用大部分Pub中的庫。

臨時使用:

PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" pub get # pub
PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" flutter packages get # flutter

長期使用:

echo 'export PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"' >> ~/.bashrc

Homebrew

brew && core && cask

設置鏡像:

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

恢復官方:

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

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

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

可用源

名稱 類型 地址
清華 brew https://mirrors.tuna.tsinghua...
清華 core https://mirrors.tuna.tsinghua...
清華 cask https://mirrors.tuna.tsinghua...
中科大 brew https://mirrors.ustc.edu.cn/b...
中科大 core https://mirrors.ustc.edu.cn/h...
中科大 cask https://mirrors.ustc.edu.cn/h...

Homebrew-bottles

臨時替換:

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

長期替換:

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

可用源

  • 中科大 - https://mirrors.ustc.edu.cn/h...
  • 清華 - https://mirrors.tuna.tsinghua...

homebrew-install

解決install腳本無法訪問問題,通過鏡像加速腳本安裝。

使用方法和官方一致:

/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"

具體食用説明點此

user avatar
0 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.