Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibGit2Sharp.Core.NativeMethods threw an exception. #2615

Closed
annie-sumpter opened this issue Mar 4, 2021 · 13 comments
Closed

LibGit2Sharp.Core.NativeMethods threw an exception. #2615

annie-sumpter opened this issue Mar 4, 2021 · 13 comments
Labels

Comments

@annie-sumpter
Copy link

Describe the bug
We use GitVersion task in multiple AzureDevOps pipelines - azure-pipelines.yaml. This tasks is now failing for all pipelines which use the latest ubuntu vmImage (ubuntu 20.04). The task is not failing on ubuntu 18.04 nor windows image.

The error looks similar to #1852 which is marked as resolved in 5.3.2 version. However Azure DevOps uses 5.0.1 version.

Expected Behavior

GitVersion task should succeed.

- task: GitVersion@5
      inputs:
        runtime: 'core'
        configFilePath: '$(Build.SourcesDirectory)/gitversion.yaml'
        updateAssemblyInfo: true

Actual Behavior

GitVersion task fails with this error:

2021-03-03T14:42:26.2984494Z ##[section]Starting: GitVersion
2021-03-03T14:42:26.2991240Z ==============================================================================
2021-03-03T14:42:26.2991800Z Task         : GitVersion Task
2021-03-03T14:42:26.2992230Z Description  : Easy Semantic Versioning (http://semver.org) for projects using Git
2021-03-03T14:42:26.2992618Z Version      : 5.0.1
2021-03-03T14:42:26.2992939Z Author       : GitVersion Contributors
2021-03-03T14:42:26.2993362Z Help         : See the [documentation](http://gitversion.readthedocs.org/en/latest/) for help
2021-03-03T14:42:26.2993823Z ==============================================================================
2021-03-03T14:42:26.7808216Z [command]/usr/bin/dotnet /home/vsts/work/_tasks/GitVersion_e5983830-3f75-11e5-82ed-81492570a08e/5.0.1/core/GitVersion.dll /home/vsts/work/1/s /output buildserver /nofetch /config /home/vsts/work/1/s/gitversion.yaml /updateassemblyinfo true
2021-03-03T14:42:27.2296875Z INFO [03/03/21 14:42:27:22] Working directory: /home/vsts/work/1/s
2021-03-03T14:42:27.2300424Z INFO [03/03/21 14:42:27:22] IsDynamicGitRepository: False
2021-03-03T14:42:27.3013440Z ERROR [03/03/21 14:42:27:30] An unexpected error occurred:
2021-03-03T14:42:27.3019228Z System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-572e4d8' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-572e4d8: cannot open shared object file: No such file or directory
2021-03-03T14:42:27.3021340Z    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
2021-03-03T14:42:27.3024434Z    at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
2021-03-03T14:42:27.3025863Z    at LibGit2Sharp.Core.NativeMethods..cctor()
2021-03-03T14:42:27.3246234Z    --- End of inner exception stack trace ---
2021-03-03T14:42:27.3282834Z    at LibGit2Sharp.Core.NativeMethods.git_buf_dispose(GitBuf buf)
2021-03-03T14:42:27.3283601Z    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever)
2021-03-03T14:42:27.3284179Z    at LibGit2Sharp.Repository.Discover(String startingPath)
2021-03-03T14:42:27.3284932Z    at GitVersion.GitPreparer.GetDotGitDirectory() in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 148
2021-03-03T14:42:27.3285818Z    at GitVersion.GitPreparer.GetProjectRootDirectory() in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 162
2021-03-03T14:42:27.3286711Z    at GitVersion.ConfigFileLocator.Verify(GitPreparer gitPreparer, IFileSystem fileSystem) in D:\a\1\s\src\GitVersionCore\Configuration\ConfigFileLocator.cs:line 57
2021-03-03T14:42:27.3287583Z    at GitVersion.Program.VerifyArgumentsAndRun() in D:\a\1\s\src\GitVersionExe\Program.cs:line 95
2021-03-03T14:42:27.3288145Z INFO [03/03/21 14:42:27:30] 
2021-03-03T14:42:27.3288715Z INFO [03/03/21 14:42:27:30] Attempting to show the current git graph (please include in issue): 
2021-03-03T14:42:27.3289335Z INFO [03/03/21 14:42:27:30] Showing max of 100 commits
2021-03-03T14:42:27.3289881Z INFO [03/03/21 14:42:27:22] Working directory: /home/vsts/work/1/s
2021-03-03T14:42:27.3290662Z INFO [03/03/21 14:42:27:22] IsDynamicGitRepository: False
2021-03-03T14:42:27.3291224Z ERROR [03/03/21 14:42:27:30] An unexpected error occurred:
2021-03-03T14:42:27.3293217Z System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-572e4d8' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-572e4d8: cannot open shared object file: No such file or directory
2021-03-03T14:42:27.3294576Z    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
2021-03-03T14:42:27.3295127Z    at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
2021-03-03T14:42:27.3295638Z    at LibGit2Sharp.Core.NativeMethods..cctor()
2021-03-03T14:42:27.3296343Z    --- End of inner exception stack trace ---
2021-03-03T14:42:27.3297253Z    at LibGit2Sharp.Core.NativeMethods.git_buf_dispose(GitBuf buf)
2021-03-03T14:42:27.3297767Z    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever)
2021-03-03T14:42:27.3298268Z    at LibGit2Sharp.Repository.Discover(String startingPath)
2021-03-03T14:42:27.3298871Z    at GitVersion.GitPreparer.GetDotGitDirectory() in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 148
2021-03-03T14:42:27.3299616Z    at GitVersion.GitPreparer.GetProjectRootDirectory() in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 162
2021-03-03T14:42:27.3300622Z    at GitVersion.ConfigFileLocator.Verify(GitPreparer gitPreparer, IFileSystem fileSystem) in D:\a\1\s\src\GitVersionCore\Configuration\ConfigFileLocator.cs:line 57
2021-03-03T14:42:27.3301485Z    at GitVersion.Program.VerifyArgumentsAndRun() in D:\a\1\s\src\GitVersionExe\Program.cs:line 95
2021-03-03T14:42:27.3302064Z INFO [03/03/21 14:42:27:30] 
2021-03-03T14:42:27.3302631Z INFO [03/03/21 14:42:27:30] Attempting to show the current git graph (please include in issue): 
2021-03-03T14:42:27.3303249Z INFO [03/03/21 14:42:27:30] Showing max of 100 commits
2021-03-03T14:42:27.3339642Z ##[error]Error: The process '/usr/bin/dotnet' failed with exit code 1
2021-03-03T14:42:27.3371225Z ##[section]Finishing: GitVersion

Context

We temporarily changed our pipelines to use ubuntu 18.04 instead of 20.04 until this is fixed.

Steps to Reproduce

Run a GitVersion task in Azure DevOps pipeline with vmImage 20.04

  • Version Used: 5.0.1
  • Operating System and version (Windows 10, Ubuntu 18.04): Ubuntu 20.04
@annie-sumpter annie-sumpter changed the title [Bug] LibGit2Sharp.Core.NativeMethods threw an exception. [Bug] Mar 4, 2021
@annie-sumpter annie-sumpter changed the title LibGit2Sharp.Core.NativeMethods threw an exception. [Bug] LibGit2Sharp.Core.NativeMethods threw an exception. Mar 4, 2021
@asbjornu
Copy link
Member

asbjornu commented Mar 4, 2021

I assume this is a compatibility issue in LibGit2Sharp and therefore nothing we can do anything about in GitVersion. 🤷🏽

@annie-sumpter
Copy link
Author

annie-sumpter commented Mar 4, 2021

I assume this is a compatibility issue in LibGit2Sharp and therefore nothing we can do anything about in GitVersion. 🤷🏽

Thanks for the quick response. Where shall I raise this issue then? AzureDevOps tasks repo?

@asbjornu
Copy link
Member

asbjornu commented Mar 4, 2021

According to @bording in libgit2/libgit2sharp#1703 (comment):

This should be fixed with the latest preview release.

So I guess we'll have to wait for a new release of LibGit2Sharp and hope it will remedy the problem.

@annie-sumpter
Copy link
Author

According to @bording in libgit2/libgit2sharp#1703 (comment):

This should be fixed with the latest preview release.

So I guess we'll have to wait for a new release of LibGit2Sharp and hope it will remedy the problem.

Thanks. I will keep an eye on it :)

@bording
Copy link
Contributor

bording commented Mar 4, 2021

So I guess we'll have to wait for a new release of LibGit2Sharp and hope it will remedy the problem.

If I'm understanding correctly, this report seems to be saying that the version of GitVersionTask being used is 5.0.1. That version is never going to work with Ubuntu 20.04 because of the bundled LibGit2Sharp in 5.0.1.

The latest version of GitVersion has started using LibGit2Sharp 0.27.0-preview-0096, right? You'll have to be using that version if you want to run on Ubuntu 20.04.

@arturcic
Copy link
Member

arturcic commented Mar 4, 2021

The latest version of GitVersion has started using LibGit2Sharp 0.27.0-preview-0096, right? You'll have to be using that version if you want to run on Unbuntu 20.04.

@bording you are correct, we updated to 0.27.0-preview-0096 starting with v5.6.0

@bording
Copy link
Contributor

bording commented Mar 4, 2021

@bording you are correct, we updated to 0.27.0-preview-0096 starting with v5.6.0

@annie-sumpter In that case, the solution is that you need to be using a newer version of GitVersion if you want it to work on Ubuntu 20.04.

@annie-sumpter
Copy link
Author

@bording you are correct, we updated to 0.27.0-preview-0096 starting with v5.6.0

@annie-sumpter In that case, the solution is that you need to be using a newer version of GitVersion if you want it to work on Ubuntu 20.04.

Thanks @bording. We use GitVersion@5 task in azure devops. I am not aware of possibility to setup an explicit version of GitVersion to be used in the task.

@arturcic
Copy link
Member

arturcic commented Mar 4, 2021

@annie-sumpter GitVersion task is deprecated, you can use https://github.com/GitTools/actions/blob/main/docs/examples/azure/gitversion/index.md instead

@annie-sumpter
Copy link
Author

Thanks @arturcic I will have a look.

@asbjornu
Copy link
Member

asbjornu commented Mar 4, 2021

Sorry for adding to the confusion. I would probably have thought twice about it if libgit2/libgit2sharp#1703 was closed as fixed and connected to a release. Yes, @annie-sumpter, please move to the supported and latest AzDO task. You can find it linked from the documentation.

@annie-sumpter
Copy link
Author

Thanks all for your advice. It was really helpful. I am posting the solution here for anyone having the same issue.

  1. We installed GitTools into Azure Devops
  2. Then we replaced GitVersion@5 deprecated task in azure-pipelines.yaml
   - task: GitVersion@5
      inputs:
        runtime: 'core'
        configFilePath: '$(Build.SourcesDirectory)/gitversion.yaml'
        updateAssemblyInfo: true

with

   - task: gitversion/setup@0
      displayName: Install GitVersion
      inputs:
        versionSpec: '5.x'
        
    - task: gitversion/execute@0
      displayName: Execute GitVersion
      inputs:
        useConfigFile: true
        configFilePath: '$(Build.SourcesDirectory)/gitversion.yaml'

@arturcic
Copy link
Member

arturcic commented Mar 5, 2021

@annie-sumpter great it worked for you, closing this issue

@arturcic arturcic closed this as completed Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants