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 @ 2019-09-17 15:38  叉叉敌  阅读(841)  评论(0编辑  收藏  举报