cake-contrib / Cake_Git

Cake AddIn that extends Cake with Git features using LibGit2 and LibGit2Sharp
https://cakebuild.net/extensions/cake-git
Other
39 stars 64 forks source link

Linux (Ubuntu): LibGit2Sharp failing with "System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so" #68

Closed evil-shrike closed 6 years ago

evil-shrike commented 6 years ago

It's related to #61 but in my case it's happening on Ubuntu Xenial (not CentOS).

I have a Docker container with TeamCity agent (FROM jetbrains/teamcity-agent) where I run my build with Cake 0.25.0. Cake script has import #addin "Cake.Git". Previously it worked fine. But yesterday I rebuilt the container to update it to using .net core 2.1 and my builds start failing.

The error is pretty typical for LibGit2Sharp - DllNotFoundException for lib/linux/x86_64/libgit2-1196807.so I checked that that module (libgit2-1196807.so) exists in Cake's tools dir, it does: /opt/buildagent/work/e1fb3d71588668ec/Build/tools/Addins/cake.git/Cake.Git/lib/net46/lib/linux/x86_64/libgit2-1196807.so

But it looks suspicious that the package is installed into net46 folder.

The error:

[19:52:42][Step 1/2] Installing Cake 0.25.0...
[19:53:30][Step 1/2] Error: One or more errors occurred.
[19:53:30][Step 1/2]    The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
[19:53:30][Step 1/2] 
[19:53:30][Step 1/2] Unhandled Exception:
[19:53:30][Step 1/2] System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
[19:53:30][Step 1/2]   at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]    --- End of inner exception stack trace ---
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00008] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options, LibGit2Sharp.Repository+RepositoryRequiredParameter requiredParameter) [0x00312] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Repository..ctor (System.String path) [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at Cake.Git.Extensions.RepositoryExtensions.UseRepository[TResult] (Cake.Core.ICakeContext context, Cake.Core.IO.DirectoryPath repositoryPath, System.Func`2[T,TResult] repositoryFunc) [0x00061] in <68d0f59d618141b69437a5843a3bbe02>:0 
[19:53:30][Step 1/2]   at Cake.Git.GitAliases.GitBranchCurrent (Cake.Core.ICakeContext context, Cake.Core.IO.DirectoryPath repositoryDirectoryPath) [0x0001c] in <68d0f59d618141b69437a5843a3bbe02>:0 
[19:53:30][Step 1/2]   at Submission#0.GitBranchCurrent (Cake.Core.IO.DirectoryPath repositoryDirectoryPath) [0x0000c] in <1937edc4fc034377b66b7353cb660d87>:0 
[19:53:30][Step 1/2]   at Submission#0+<<Initialize>>d__0.MoveNext () [0x0058f] in <1937edc4fc034377b66b7353cb660d87>:0 
[19:53:30][Step 1/2] --- End of stack trace from previous location where exception was thrown ---
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState+<RunSubmissionsAsync>d__9`1[TResult].MoveNext () [0x00186] in <7d37a385ddd24eeb96bd540d739cc157>:0 
[19:53:30][Step 1/2] --- End of stack trace from previous location where exception was thrown ---
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject.Finalize () [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2] [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
[19:53:30][Step 1/2]   at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]    --- End of inner exception stack trace ---
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00008] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options, LibGit2Sharp.Repository+RepositoryRequiredParameter requiredParameter) [0x00312] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Repository..ctor (System.String path) [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at Cake.Git.Extensions.RepositoryExtensions.UseRepository[TResult] (Cake.Core.ICakeContext context, Cake.Core.IO.DirectoryPath repositoryPath, System.Func`2[T,TResult] repositoryFunc) [0x00061] in <68d0f59d618141b69437a5843a3bbe02>:0 
[19:53:30][Step 1/2]   at Cake.Git.GitAliases.GitBranchCurrent (Cake.Core.ICakeContext context, Cake.Core.IO.DirectoryPath repositoryDirectoryPath) [0x0001c] in <68d0f59d618141b69437a5843a3bbe02>:0 
[19:53:30][Step 1/2]   at Submission#0.GitBranchCurrent (Cake.Core.IO.DirectoryPath repositoryDirectoryPath) [0x0000c] in <1937edc4fc034377b66b7353cb660d87>:0 
[19:53:30][Step 1/2]   at Submission#0+<<Initialize>>d__0.MoveNext () [0x0058f] in <1937edc4fc034377b66b7353cb660d87>:0 
[19:53:30][Step 1/2] --- End of stack trace from previous location where exception was thrown ---
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:31][Step 1/2]   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState+<RunSubmissionsAsync>d__9`1[TResult].MoveNext () [0x00186] in <7d37a385ddd24eeb96bd540d739cc157>:0 
[19:53:31][Step 1/2] --- End of stack trace from previous location where exception was thrown ---
[19:53:31][Step 1/2]   at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject.Finalize () [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
evil-shrike commented 6 years ago

Tried to pin to the previous version:

#addin nuget:?package=Cake.Git&version=0.16.1

didn't help

evil-shrike commented 6 years ago

Well it's not a problem of Cake.Git, it's issue with LibGit2Sharp. It turned out that installing libcurl3 solves the problem.

johnkors commented 6 years ago

Thanks, @evil-shrike.