Git for Windows-程序无法启动,因为 libiconv2.dll 丢失

当我试图在 Windows 7(64位)的 git Bash 上运行某些命令(例如 git push)时,我得到了错误:

The program can't start because libiconv2.dll is missing from your computer

我已经竭尽全力地寻找解决这个问题的办法。
我能找到的最多是一个问题的线程在谷歌代码网站(第419期)和一些其他博客在这里和那里。据我所知,这些帖子中提出的任何建议实际上都不能解决我的问题。

我试过重新安装。我试过将 $GIT/bin添加到 PATH
我可以验证 dll 是否在 $GIT/bin目录中... ... 但我仍然不能推到远程。

我有一个工作安装的 msysgit 在另一个 Windows 7框,我安装的方式相同,在这两种情况下... 所以不用说,我相当困惑。

如果你能帮忙,我将不胜感激。

谢谢,

90001 次浏览

Fastest way to fix this is locating the *.dll file on the other pc and copy it =)

I have msysgit on Windows7 without any issue with any DLL.

I have libiconv2.dll in the bin directory: C:\Path\To\Git\1.7.1\bin

The issue 419 was about someone who installed the "development environment to compile Git for Windows", not just Git.
See this SO answer for the difference between the two.

So which one did you install?

  • Git-1.x.x.x...? (like 'Git-1.7.0.2-preview20100309.exe'),
  • or msysGit-netinstall-1.x.x...? (like 'msysGit-netinstall-1.7.1-preview20100612.exe').

I have resolved this...there are a couple of things to note here.

1) The problem was a typo in my configured origin in my local .git/config file...So I'm an idiot.

2) Git Bash does not fail gracefully in this situation, and then throws this very misleading error as an alert, rather than reporting that there is no configured origin of the name specified in the .git/config file.

The only way I was able to figure this out was by adding the $GitPath/cmd directory to my path and running git from the command line. There, I was able to get a verbose error message indicating that the remote repository did not yet exists. Then I pulled up the trusty vi editor and saw there was in fact a typo.

The lesson here. If you are getting a weird .dll error with msysgit, it could very likely be the result of a misconfiguration...rather than some system anomaly or install issue.

Thanks to everyone who tried to help with this!

I saw this error with msysGit-fullinstall-1.7.3.1-preview20101002.exe on Win 7.

Added <msysgit_dir>\mingw\bin to PATH

fix it. libiconv2.dll was found in that directory.

Work around from this thread: http://groups.google.com/forum/#!topic/msysgit/twrVn_EbNI4

  • cd into your git install directory
  • copy mingw\bin\libiconv-2.dll libexec\git-core
    (or copy bin\libiconv-2.dll libexec\git-core if your installation has no mingw folder)

In the linked thread Drew asks for assistance, so if you think you can help fix it you might want to reply in that Google Groups thread.

Error happens with these builds:

  • msysgit-fullinstall-1.7.4 OR 1.7.6 (and 1.7.7)
  • msysgit-netinstall-1.7.4 OR 1.7.6 (and 1.7.7)
  • Git For Windows 1.7.6 (but not 1.7.4)
  • copy /Program Files/Git/bin/libiconv-2.dll
  • to /Program Files/Git/libexec/git-core/

To resolve this issue I actually had to copy all DLLs from mingw/bin/ to bin/ (not overwriting any existing once). I use remote HTTPs repositories and it just kept on complaining.

I originally tried to solve this problem by copying the dll as mentioned here but soon ran into other problems. For me the real solution was to set the path in my .bashrc file for msys to prioritize the msys binaries.

Open the msys shell and the following line in ~/.bashrc:

export PATH=/usr/local/bin:/mingw/bin:/bin:$PATH

I just tried installing SmartGIT on Windows and facing the same problem. I just figure out that it works not by pointing it to git.exe, instead I pointed it to C:\msysgit\cmd\git.cmd. So far it works just fine. I can access the git repository under msysgit.

FYI, I'm using the Net installer for Windows.

Hoping that this is the right approach.

My answer resolves the same error for msysgit, but may help with pure git.

On Windows 7, I added <msysgit_dir>\mingw\bin to PATH as so_mv has recommended above (via the System Variables GUI), but I had to logout and login to OS after that, otherwise the PATH value won't get updated.

I had the same error on Windows 7 when running \msysgit\bin\git.exe. I fixed it by copying the \msysgit\mingw\bin\libiconv-2.dll to the root of Win 7 installation directory.

As SmartGit references this page of stackoverflow in error result i think this knowledge might be useful for someone here....

Sometimes although there is no problem with git installation. Even if you can use git bash and get version information by typing

git -- version

SmartGit doesn't add repository and returns git is obsolote or version information is cannot be fetched (or similar to this message)...

If so, you'd better check your security utilities and virus removal applications settings first. In my situation disabling comodo firewall make smartgit able to see healty git installation and version information.

I've been plagued with this issue, to correct this issue, i uninstalled tortoisegit and msysgit, then i reinstalled "Git-1.8.1.2-preview20130201".

by doing this, this corrected my issue and i'm not able to use poshgit.

Variation of sqzaman's answer, as I did not have the folders in the same place they did:

Copy
%USERPROFILE%\Local Settings\Application Data\GitHub\PortableGit_*\bin\*.dll
to
%USERPROFILE%\Local Settings\Application Data\GitHub\PortableGit_*\libexec\git-core

Note that I started by copying libiconv-2.dll, but then it complained about libcurl.dll so I went ahead and copied *.dll

I installed Git for Windows, then Git in order to copy the .dll

This did not work for me. To solve the issue I had to add the path:

C:\Users\*username*\AppData\Local\GitHub\PortableGit_015aa71ef18c047ce8509ffb2f9e4bb0e3e73f13\cmd

to the PATH environment variable.

This cleared up the issue and I can now access git from the command prompt.

I had to deal with this same error message while trying to configure meanio, of which git is a prerequisite (my particular error was: prerequisite not found: git).
The fix I figured out entailed copying libiconv2.dll from

C:\Program Files (x86)\Git\bin

to

C:\Program Files (x86)\Git\libexec\git-core

Then I had to make some adjustments to the windows system Environment Variables (Right click computer, go to properties, click "Advanced System Settings" on the left vertical bar, select environment variables) Once in Environment Variables, look in the System Variables box. Find the

PATH

Variable and add three new references:

C:\Program Files (x86)\Git\bin;
C:\Program Files (x86)\Git\cmd;
C:\Program Files (x86)\Git\libexec\git-core

This way all the required git files are accessible across the system path.

Hope this helps!

In my case I used chocolatey (chocolatey.org) to install git.

I had to copy libconv-2.dll to C:\ProgramData\chocolatey\bin to get it working. I'm not sure if copying the file to C:\Program Files (x86)\Git\libexec\git-core is also necessarily, as I did that first.

Personally I solved it by reading the error I got from getopt.exe, that told me it was missing "libiconv2.dll".. I had libiconv-2.dll (notice the dash "-") in C:\Program Files (x86)\Git\bin. Making a copy and naming it libiconv2.dll did the trick for me...

I used some chocolatey packages ... maybe the actual file was renamed during its development lifetime... and the dependencies in the packages did not....

Well hope it helps someone out there :)

If the error "missing libiconv-2.dll" occurs while starting SourceTree on Windows, following worked for me (Win 8.1):

go to

C:\Users\$USERNAME$\AppData\Local\Atlassian\SourceTree\git_local\bin

copy

libcrypto.dll
libcurl.dll
libiconv-2.dll
libssl.dll

to

C:\Users\$USERNAME$\AppData\Local\Atlassian\SourceTree\git_local\libexec\git-core

I was using GitHub Desktop Version and having same problem, I changed Default shell by Setting-->Options--->Default shell and checked Git bash. I started "Open Git shell" and run "git pull" command, it fixed problem. It worked in my case.

Copy all .dlls from:

C:\Users\YOURUSERNAME\AppData\Local\GitHub\PortableGit_25d850739bc178b2eb13c3e2a9faafea2f9143c0\mingw32\bin

to:

C:\Users\YOURUSERNAME\AppData\Local\GitHub\PortableGit_25d850739bc178b2eb13c3e2a9faafea2f9143c0\mingw32\libexec\git-core

One possible solution for SourceTree:

   1.Open the "Option" window.
2.Select "Git".
3.Than "Use System Git".
4.And press OK button.

Had this problem in SmartGit on mac. Fixed it by changing in Preferences -> Commands -> Executable

Git Executable:

from

/usr/bin/git

to:

/usr/local/git/bin/git

I had the same problem, I am using Windows 10 and it is super easy to solve this problem.

Download the dll file from:

https://www.dll-files.com/libiconv-2.dll.html

extract it or paste it into the mingw folder directly, it's generally in C- drive if you have installed it using default options. Hope it helps.

Try the following command:

sudo rm -rf /Library/Developer/CommandLineTools

and install developer tools