You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
libgit2sharp is failing to load the native DLLs if the directory path contains %2F
How did I get in this state? Our Jenkins build checks out GitHub repositories with the branch name in them. In my case, the branch name was in the format features/dev10 with a forward slash in the branch name.
That branch path in Windows ends up being C:\jenkins\workspace\features%2Fdev10\
This failure can be easily reproduced in libgit2sharp by setting the Output Path of LibGit2Sharp.Tests to busted%2Fdirectory\
I've tracked the problem down to GlobalSettings.cs, lines 22-31:
It looks like creating a Uri out of the current path turns the legit %2F in the directory name back into a forward slash.
After that, the DLL load mechanism fails to find the native git2.dll in NativeMethods.cs because it adds an invalid directory to the PATH environment variable
I hit this issue using Cake and the GitVersion tool which in turn uses libgit2sharp
In the meantime, I might be able to add the DLL directory to my PATH environment variable before calling GitVersion as a workaround. Also not putting forward slashes in the git branch names will work around this issue with Jenkins putting the %2F in the directory name.
Stack trace below
14:35:43 Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-381caf5': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
14:35:43 at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
14:35:43 at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()
14:35:43 at LibGit2Sharp.Core.NativeMethods..cctor()
14:35:43 --- End of inner exception stack trace ---
14:35:43 at LibGit2Sharp.Core.NativeMethods.RemoveHandle()
14:35:43 at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject.Finalize()```
The text was updated successfully, but these errors were encountered:
libgit2sharp is failing to load the native DLLs if the directory path contains
%2F
How did I get in this state? Our Jenkins build checks out GitHub repositories with the branch name in them. In my case, the branch name was in the format
features/dev10
with a forward slash in the branch name.That branch path in Windows ends up being
C:\jenkins\workspace\features%2Fdev10\
This failure can be easily reproduced in libgit2sharp by setting the Output Path of
LibGit2Sharp.Tests
tobusted%2Fdirectory\
I've tracked the problem down to
GlobalSettings.cs
, lines 22-31:It looks like creating a
Uri
out of the current path turns the legit%2F
in the directory name back into a forward slash.After that, the DLL load mechanism fails to find the native
git2.dll
inNativeMethods.cs
because it adds an invalid directory to thePATH
environment variableI hit this issue using Cake and the GitVersion tool which in turn uses libgit2sharp
In the meantime, I might be able to add the DLL directory to my PATH environment variable before calling GitVersion as a workaround. Also not putting forward slashes in the git branch names will work around this issue with Jenkins putting the %2F in the directory name.
Stack trace below
The text was updated successfully, but these errors were encountered: