Git / Bower 错误:退出代码 # 128 和连接失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21544803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git / Bower Errors: Exit Code # 128 & Failed connect
提问by azsl1326
I am using Bower to install several libraries. For demonstration purposes here, I am installing bootstrap. Regardless of the package, I receive the following errors:
我正在使用 Bower 安装多个库。出于演示目的,我正在安装引导程序。不管包是什么,我都会收到以下错误:
C:\Scott>bower install bootstrap
bower not-cached git://github.com/twbs/bootstrap.git#*
bower resolve git://github.com/twbs/bootstrap.git#*
bower ECMDERR Failed to execute "git ls-remote --tags --heads git://github
.com/twbs/bootstrap.git", exit code of #128
Additional error details:
fatal: unable to access 'https://github.com/twbs/bootstrap.git/': Failed connect
to github.com:443; No error
I have tried using the following solution to remove the first error - which I found from this search:
我曾尝试使用以下解决方案来删除第一个错误 - 我从本次搜索中发现:
git config --global url."https://".insteadOf git://
However, this does not work nor do any of the other solutions found on that page. Searching for a solution for the 2nd error, it seems that setting a username/pwd for a proxy server will resolve the issue if you are on a corporate network/behind a firewall. However, I am not using a proxy server as I am on my home pc/network (windows 7 x64).
但是,这不起作用,该页面上的任何其他解决方案也不起作用。寻找第二个错误的解决方案,如果您在公司网络上/在防火墙后面,为代理服务器设置用户名/密码似乎可以解决问题。但是,我没有使用代理服务器,因为我在家用电脑/网络(Windows 7 x64)上。
Thanks!
谢谢!
EDIT: Command window with errors:
编辑:有错误的命令窗口:
采纳答案by azsl1326
Port 22 was being blocked on my computer. Once I found what was blocking it and opened the port, I was able to run the bower install cmd without any issues.
端口 22 在我的计算机上被阻止。一旦我发现了什么阻止了它并打开了端口,我就可以毫无问题地运行 bower install cmd。
回答by ablais
I know this is not "fixing" the problem, but you can use
我知道这不是“解决”问题,但您可以使用
git config --global url."https://".insteadOf git://
git config --global url."https://".insteadOf git://
to tell git to use HTTPS instead of GIT which worked out for me to install npm dependencies.
告诉 git 使用 HTTPS 而不是 GIT,这让我可以安装 npm 依赖项。
回答by antonjs
Instead to run this command:
而是运行此命令:
git ls-remote --tags --heads git://github.com/twbs/bootstrap.git
you should run this command:
你应该运行这个命令:
git ls-remote --tags --heads [email protected]:twbs/bootstrap.git
or
或者
git ls-remote --tags --heads https://github.com/twbs/bootstrap.git
or you can run git ls-remote --tags --heads git://github.com/twbs/bootstrap.git
but you need to make git always use https in this way:
或者你可以运行,git ls-remote --tags --heads git://github.com/twbs/bootstrap.git
但你需要让 git 总是以这种方式使用 https:
git config --global url."https://".insteadOf git://
Reference: https://github.com/bower/bower/issues/50
回答by Frank Fu
I came across this with my corporate network.
我在我的公司网络中遇到了这个问题。
It seemed strange because I've always been using ssh to connect with git and never had an issue.
这看起来很奇怪,因为我一直使用 ssh 连接 git 并且从未遇到过问题。
I tried https and didn't work so I added proxy settings to git's config and all was well
我尝试了 https 但没有用,所以我在 git 的配置中添加了代理设置,一切都很好
git config --global http.proxy http://proxyuser:[email protected]:8080
git config --global https.proxy https://proxyuser:[email protected]:8080
And making sure it worked
并确保它有效
git config --list
回答by Henry
It appears as though azsl1326 failed to use bower (git) over port 9418 (git://), then told git to use port 22 (https://) instead. This was still failing, but then opening port 22 got the desired result.
似乎 azsl1326 未能通过端口 9418 (git://) 使用 bower (git),然后告诉 git 使用端口 22 (https://)。这仍然失败,但是打开端口 22 得到了预期的结果。
The most direct solution is to open port 9418. This is the port that the git:// protocol uses.
最直接的解决办法就是打开9418端口,这是git://协议使用的端口。
回答by Ignatius Andrew
Navigate to your Application Folder and run this command
导航到您的应用程序文件夹并运行此命令
git config --global url."https://".insteadOf "git://
git config --global url."https://".insteadOf "git://
"
”
This should fix your issue
这应该可以解决您的问题
回答by Kit
Perhaps you need to generate an ssh keyso you are authenticated with github.
也许您需要生成一个 ssh 密钥,以便通过 github 进行身份验证。
回答by Steve Neal
Are you behind a firewall?
你在防火墙后面吗?
Git doesn't pick up the proxy configuration when it's called, so set environment variables explicitly, e.g.:
Git 在被调用时不会获取代理配置,因此明确设置环境变量,例如:
export HTTP_PROXY=http://username:password@proxyserver:port/
export HTTPS_PROXY=http://username:password@proxyserver:port/
If your corporate proxy doesn't need authentication just omit the username:password@
bit in the URLs.
如果您的公司代理不需要身份验证,只需省略username:password@
URL 中的位。
It worked for me!
它对我有用!
回答by Dahar Youssef
If your country block github, e.g. China mainland, then you can build a proxy, e.g. use goagent & gae, then set proxy address for git, e.g.
如果你的国家屏蔽了github,比如 CN 大陆,那么你可以建立一个代理,比如使用goagent & gae,然后为git设置代理地址,比如
git config --global http.proxy 127.0.0.1:8087
回答by TwystO
This error is related to a bad configuration of your firewall. You will notice that bower trying to contact git via the git://
protocol and not http://
. You have to open port 9418
. Add this two lines in your iptables configuration :
此错误与防火墙的错误配置有关。您会注意到 bower 试图通过git://
协议而不是.git 联系 git http://
。你必须打开端口9418
。在您的 iptables 配置中添加这两行:
iptables -t filter -A INPUT -p tcp --dport 9418 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 9418 -j ACCEPT
This should do the trick.
这应该可以解决问题。