让Pharo使用代理访问github

Metacello 在下载传统的 .mcz 文件(通常是 HTTP)和下载 Git 仓库(如 GitHub 项目)时,使用的网络组件是不同的。

  1. 对于 http:// 或 https:// 开头的源(例如传统的 SqueakSource 或 SmalltalkHub),它底层使用的是 Zinc HTTP Components。这部分直接使用 Pharo 的全局网络设置,在 Playground 中执行:
NetworkSystemSettings useHTTPProxy: true.
"HTTPS可能需要单独设置,也可能不需要"
"NetworkSystemSettings useHTTPSProxy: true." 
NetworkSystemSettings httpProxyHost: '127.0.0.1'.
NetworkSystemSettings httpProxyPort: 10809. 
  1. 针对 github 或其它 git 仓库,底层会调用 Iceberg,而 Iceberg 使用的是 Libgit2. Libgit2 不一定会直接读取 Pharo 那个 NetworkSystemSettings 的设置,它更多依赖操作系统的环境变量。
export http_proxy=http://127.0.0.1:10809
export https_proxy=http://127.0.0.1:10809
./pharo-ui Pharo.image

或者在Pharo中直接修改环境变量:

OSPlatform current environment at: 'http_proxy' put: 'http://127.0.0.1:10809'.
OSPlatform current environment at: 'https_proxy' put: 'http://127.0.0.1:10809'.

[补充] 上述环境变量似乎只有 https_proxy 起作用,如果单独设置 http_proxy并不起作用。

还有一个方法,就是配置 git 全局参数:

git config --global http.proxy http://127.0.0.1:10809
# 取消代理
git config --global --unset http.proxy

评论

暂无评论