fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle解决版本

现象

fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 110] Connection timed out

根本原因

repo工具是一个python脚本,里面有个方法_InitHttp,检测到http_proxy在环境变量中就会用他,如果环境变量是一个无效的,那么就会报错。所以要么时候一个有效的,或者就没有这个环境变量。

def _InitHttp():
  handlers = []

  mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
  try:
    import netrc
    n = netrc.netrc()
    for host in n.hosts:
      p = n.hosts[host]
      mgr.add_password(p[1], 'http://%s/' % host, p[0], p[2])
      mgr.add_password(p[1], 'https://%s/' % host, p[0], p[2])
  except:
    pass
  handlers.append(urllib.request.HTTPBasicAuthHandler(mgr))
  handlers.append(urllib.request.HTTPDigestAuthHandler(mgr))

  if 'http_proxy' in os.environ:
    url = os.environ['http_proxy']
    handlers.append(urllib.request.ProxyHandler({'http': url, 'https': url}))
  if 'REPO_CURL_VERBOSE' in os.environ:
    handlers.append(urllib.request.HTTPHandler(debuglevel=1))
    handlers.append(urllib.request.HTTPSHandler(debuglevel=1))
  urllib.request.install_opener(urllib.request.build_opener(*handlers))

解决方法

  1. 如果是本地需要代理,就设置一个代理
set http_proxy=http://user:pass@host:port
set https_proxy=https://user:pass@host:port
  1. 不需要代理就unset 代理即可
unset https_proxy
unset http_proxy
  1. 永久的移除或者添加一个代理
cat /etc/enviroment

我还分享在这里了
https://stackoverflow.com/questions/38594080/fatal-cannot-get-https-gerrit-googlesource-com-git-repo-clone-bundle-fatal-e/57968927#57968927

posted @   叉叉敌  阅读(875)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示