Git/Bower 错误: 退出代码 # 128 & 连接失败

我正在使用 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

我尝试使用以下解决方案来删除第一个错误-这是我从这个 搜索中发现的:

git config --global url."https://".insteadOf git://

但是,这不起作用,在该页面上找到的任何其他解决方案也不起作用。正在寻找第二个错误的解决方案,似乎为代理服务器设置用户名/pwd 可以解决您在公司网络/防火墙后面的问题。但是,我不使用代理服务器,因为我在我的家庭电脑/网络(Windows 7 x64)。

谢谢!

编辑: 带有错误的命令窗口:

enter image description here

100493 次浏览

Perhaps you need to generate an ssh key so you are authenticated with github.

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 git@github.com: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 config --global url."https://".insteadOf git://

Reference: https://github.com/bower/bower/issues/50

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.

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.

The most direct solution is to open port 9418. This is the port that the git:// protocol uses.

I know this is not "fixing" the problem, but you can use

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.

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 :

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.

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.

I tried https and didn't work so I added proxy settings to git's config and all was well

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
git config --global https.proxy https://proxyuser:proxypwd@proxy.server.com:8080

And making sure it worked

git config --list

Am adding my answer here as this is one of the closest questions that matched my situation. Was trying to install select2 rather than bootstrap, but the outcome was the same.

bower install select2 reported that git was unable to locate the directory. Used the

git config --global url."https://".insteadOf git://

config fix, but that resulted in a (paraphrased) error

I can't use https

My issue was resolved unsatisfactorily, as it involves magic.

I was attempting to run this in a command shell (cmd.exe, windows). I ran the same command and ran it in powershell and it worked. ಠ_ಠ

tl;dr: combination of https:// and powershell worked for me

I got this error after my virus checker had quarantined a download from github.com. For some unknown reason.

After I cleared those files (exe files) everything worked.

Are you behind a firewall?

Git doesn't pick up the proxy configuration when it's called, so set environment variables explicitly, e.g.:

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.

It worked for me!

git config --global url. "https://".insteadOf "git://"

was not working for me. So I found this alternative:

Go to your temp folder. ( i.e. if you are using windows then C:\Users\{username}\AppData\Roaming\bower\cache\packages ). There you can see several files. Open each of them and you can see the URL. Change it from git://... to https://... and save all files.

Now run the bower install.

Check your git config settings (git config --global --edit). In my case there were a couple of no longer valid entries like:

[core]
gitproxy=gitproxy.cmd
["https://"]
["https://"]
[url "https://"]

Revise them and remove if you don't need them anymore.

Your keys are wrong. Just add them to GitHub/Bitbucket/whatever you are using. It's nothing more than a permission issue with your keys.

Navigate to your Application Folder and run this command

git config --global url."https://".insteadOf "git://

"

This should fix your issue

However, I am not using a proxy server as I am on my home pc/network

Had the same problem (getting exit code 128) on my home network and was quite sure i was not using a proxy. Turns out, Git had saved a proxy i had entered some time in the past - after looking around in the configs, i found it under the [http] tag.

I'm new to Git, and i'm not at all sure, if those configs are usually easily accessible - am using Tortoise Git, since i'm not doing anything fancy really and that has a GUI for the things.

Hope the "answer" helps nonetheless.

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.

git config --global http.proxy 127.0.0.1:8087

In my case was the folder access where i was during the command execution! On windows I created the folder first by command line: mkdir "MyFolder" and I had the error. but if I create the folder with the mouse, right click, create folder etc. Works fine!

If you are authenticating with bitbucket, where I'm getting error 128 & Failed connect. but when using authenticating git hub its working fine.

I know this is an old question, anyway let me add one more thing.

Sometimes(If you are in an office or private network) your gateway server firewall block the https requests(port 443) from the command terminal

git config --global url."http://".insteadOf "https://"

Use this to config the git to use http over https for those situvations

This worked for me,

Copy the file "libcurl.dll" in Git installation folder ( C:\Program Files\Git\bin\libcurl.dll ). Paste it in location where the git.exe exists ( C:\Program Files\Git\libexec\git-core ).

Firstly, you should check if Visual Studio Command prompt recognizes git command: Tools > Command Line

C:\....\> git

if this command is not recognized, you should add git folder into Environment Variables

https://stackoverflow.com/a/26620861/3449657

This is what I was missing and did the trick for me.

Hope it helps.

Run these 2 commands to grant git access via your system

eval `ssh-agent`
ssh-add ~/.ssh/id_rsa

These commands are assuming that you have ssh key over the remote git server(bitbucket/github/other)

I ran into this error too, and resolved by updating git. When I ran the failed git ls-remote command, the underlying error was that an old tls version was being used. So updated version of git uses later version of tls.

https://git-scm.com/download/win

i found this error on my linux os. and i solve this problem 1. open curl log export GIT_CURL_VERBOSE=1 2.clone git repo 3. find the log 4. i fix the problem by update nss and curl (yum update nss nss-util nspr curl)