gitgithubgit-clone

Why did Git throw "Failed to load library 'libcurl-4.dll'" while cloning?


I was cloning my private GitHub repository to a local repository, but Git threw an error:

$ git clone https://github.com/Charley2012/CHMS.git D:\homes\charley\编程\编程\C\CHMS\CHMS.git
Cloning into 'D:\homes\charley\编程\编程\C\CHMS\CHMS.git'...
fatal: failed to load library 'libcurl-4.dll'

I have used cmd.exe (Windows command prompt) and Git Bash, but they both threw the same error message above. I have reinstalled Git but that does not make any difference.
I have tried to clone other GitHub repositories but I got the same error message.
GitHub Desktop has successfully cloned the repository, but the reason behind this success is unclear.

I think the problem was caused by a local reason.
I am using Windows 10 and Git 2.41.0.
The files of Git (e.g.git.exe) is under D:\homes\charley\编程\编程\DevTools\Git\cmd.


Solution

  • Since this is me answering my own question, after reinstalling Git to a different directory, the problem was solved.

    I found out that the cause of the problem was that the directory that Git was under was D:\homes\charley\编程\编程\DevTools\, and that directory contain Chinese characters "编程". The new directory of Git is S:\Charley\DevTools\, a directory that doesn't contain special characters.

    The command line message of the cloning:

    $ git clone https://github.com/Charley2012/CHMS.git E:\charley\编程\编程\C\CHMS\CHMS.git
    Cloning into 'E:\charley\编程\编程\C\CHMS\CHMS.git'...
    remote: Enumerating objects: 15, done.
    remote: Counting objects: 100% (15/15), done.
    remote: Compressing objects: 100% (13/13), done.
    remote: Total 15 (delta 2), reused 0 (delta 0), pack-reused 0
    Receiving objects: 100% (15/15), done.
    Resolving deltas: 100% (2/2), done.
    Updating files: 100% (3/3), done.  
    

    In my opinion, because the directory of Git contain Chinese characters, Git can't access libcurl-4.dll correctly because of problem converting UTF-8 characters to GBK (GB2312), or something similar.