国内镜像源(NPM, Cargo, Rustup)
记录各种包管理工具的国内镜像源 url 与设置方式
NPM
1
| https://registry.npmmirror.com
|
1
| npm config set registry https://registry.npmmirror.com
|
1
| npm i -g pnpm --registry=https://registry.npmmirror.com
|
npm 设置代理
1 2 3
| npm config set proxy http://127.0.0.1:8080
npm config set https-proxy http://127.0.0.1:8080
|
PIP
1 2 3 4 5 6 7 8 9 10 11
| pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set global.index-url https://pypi.douban.com/simple/
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/
|
pip 设置代理
1 2 3 4 5
| pip config set global.proxy http://127.0.0.1:8080
pip config set global.http_proxy http://127.0.0.1:8080 pip config set global.https_proxy http://127.0.0.1:8080
|
Rustup
修改环境变量 RUSTUP_DIST_SERVER (默认值为 https://static.rust-lang.org) 和 RUSTUP_UPDATE_ROOT (默认值为 https://static.rust-lang.org/rustup)的值为墙内镜像源:
1 2 3 4 5 6 7 8 9
| RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
RUSTUP_DIST_SERVER=https://mirrors.sjtug.sjtu.edu.cn/rust-static/
|
Cargo
打开 C:\Users<用户名>.cargo\config 文件, 如果没有则新建一个, 输入以下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| [source.crates-io] registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'rsproxy'
[source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index"
[source.tuna] registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
[source.sjtu] registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
[source.rustcc] registry = "git://crates.rustcc.cn/crates.io-index"
[source.rsproxy] registry = "https://rsproxy.cn/crates.io-index" [source.rsproxy-sparse] registry = "sparse+https://rsproxy.cn/index/" [registries.rsproxy] index = "https://rsproxy.cn/crates.io-index"
[net] git-fetch-with-cli=true
|
如果更换 cargo 源后执行 cargo build 命令出现如下错误:
1
| blocking waiting for file lock on package cache lock
|
可以删除 C:\Users<用户名>.cargo.package-cache 文件
Git 本地代理
1 2 3 4 5 6 7 8
| git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy http://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
|