libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

Clone fails with LibGit2SharpException: Failed to mmap

Open Kayak58 opened this issue 12 years ago • 48 comments

Trying to clone a remote repository using LibGit2Sharp v.0.18.1.0 throws this exception:

LibGit2Sharp.LibGit2SharpException: Failed to mmap. Invalid handle value: The volume for a file has been externally altered so that the opened file is no longer valid.

at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)

Using the same url and workdir, I have successfully cloned the repository both using Git Bash and SourceTree. But for my task I need to do it programatically, and LibGit2Sharp seemed like a good choice.

Kayak58 avatar Aug 20 '14 08:08 Kayak58

Ah, thanks @carlosmn - I didn't think to try an older libgit2, I only failed to repro this in master.

This does seem related then to git for windows and its over generous keep alive handling.

Thanks!

ethomson avatar Aug 24 '14 16:08 ethomson

@gep see #798 ;-) Once it's merged, i'll issue a new NuGet package.

Perfect, thanks! I will keep an eye out for it! :-)

gep13 avatar Aug 24 '14 16:08 gep13

@gep13 Here's another custom build for you to test: https://www.dropbox.com/s/iw3jm7536twecwx/Build.v0.19.7z?dl=0

It's basically #798. You'll slightly have to update your code to make it work with the new callback based credentials providing mechanism. See this test for some guidance.

nulltoken avatar Aug 24 '14 16:08 nulltoken

@gep13 If that's cool with you, I'd rather have you give a test to the custom build above before merging the PR.

nulltoken avatar Aug 24 '14 16:08 nulltoken

@nulltoken your wish is my command :-)

I have downloaded the above custom build, and swapped out the references in my sample project, and I am happy to report that it all seems to be working :-)

gep13 avatar Aug 24 '14 18:08 gep13

@gep13 You're amazing!

I am happy to report that it all seems to be working :-)

Great! Just a question: Did you perform the Clone() by providing credentials?

/cc @carlosmn

nulltoken avatar Aug 24 '14 19:08 nulltoken

For the first test, no, since I was using anonymous access to the repository (which is only available internally).

However, since you mentioned there was a new CredentialsProvider, I thought it would be prudent to test that as well while I was there. So I re-ran the test, after switching off anonymous access, and provided my credentials, and that test also worked :-)

gep13 avatar Aug 24 '14 19:08 gep13

Awesome!

nulltoken avatar Aug 24 '14 19:08 nulltoken