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

  • 2019 年 10 月 5 日
  • 筆記

版權聲明:本文為部落客原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。

本文鏈接:https://blog.csdn.net/weixin_42514606/article/details/100927076

現象

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

Tags: