开发常用软件镜像加速收集

794 阅读1分钟

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

可用源地址

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/

可用源地址

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'

可用源地址

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 mirrors.tuna.tsinghua.edu.cn/git/homebre…
清华 core mirrors.tuna.tsinghua.edu.cn/git/homebre…
清华 cask mirrors.tuna.tsinghua.edu.cn/git/homebre…
中科大 brew mirrors.ustc.edu.cn/brew.git
中科大 core mirrors.ustc.edu.cn/homebrew-co…
中科大 cask mirrors.ustc.edu.cn/homebrew-ca…

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

可用源

homebrew-install

解决install脚本无法访问问题,通过镜像加速脚本安装。

使用方法和官方一致:

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

具体食用说明点此