GitTools / GitVersion

From git log to SemVer in no time
https://gitversion.net/docs/
MIT License
2.85k stars 649 forks source link

[ISSUE]: n unexpected error occurred: LibGit2Sharp.LibGit2SharpException: No error message has been provided by the native library #4010

Closed hephie closed 1 month ago

hephie commented 5 months ago

Prerequisites

GitVersion package

GitVersion.Tool

GitVersion version

5.12.0

Operating system

Windows

What are you seeing?

Hi,

From time to time, I dont know what triggers it, the dotnet-gitversion command is failing when running in our CI/CD pipeline. We are using gitlab, with an onpremise gitlab runner running on a Windows Server.

From time to time, when the dotnet-gitversion.exe is run from the pipeline, we get this output. (see below). Our server/proxy/network is quite slow, so in orde to speed up things, we have this in our .gitlab-ci.yml file to speed up the code/repo checkout process:

variables: GIT_STRATEGY: fetch

The only way I found to fix issue is change this to change the GIT_STRATEGY to clone, but then it takes like 15min more every time to run the pipeline. I really wonder whats wrong, or what is triggering this error. Or if its a bug in the dotnet-gitversion.

Has any one seen this?

Running dotnet-gitversion...build: dotnet-gitversion INFO [04/22/24 16:41:00:53] Applicable build agent found: 'GitLabCi'. INFO [04/22/24 16:41:00:57] Working directory: G:\bosa-gitlab-runner\builds\D24jcpjs\0\dg-r_o\selection\selor-business INFO [04/22/24 16:41:00:62] Project root is: G:\bosa-gitlab-runner\builds\D24jcpjs\0\dg-r_o\selection\selor-business INFO [04/22/24 16:41:00:62] DotGit directory is: G:\bosa-gitlab-runner\builds\D24jcpjs\0\dg-r_o\selection\selor-business.git INFO [04/22/24 16:41:00:62] Branch from build environment: bugfix/DM-137-eind-pv-niet-getekend-waarschuwing-transfer-laureatenlijst INFO [04/22/24 16:41:00:62] Begin: Normalizing git directory for branch 'bugfix/DM-137-eind-pv-niet-getekend-waarschuwing-transfer-laureatenlijst' INFO [04/22/24 16:41:00:66] One remote found (origin -> 'https://gitlab-ci-token:*******@code.bosa.fgov.be/dg-r_o/selection/selor-business.git'). INFO [04/22/24 16:41:00:66] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories INFO [04/22/24 16:41:00:70] Updating local branch bugfix/DM-137-eind-pv-niet-getekend-waarschuwing-transfer-laureatenlijst to match ref bugfix/DM-137-eind-pv-niet-getekend-waarschuwing-transfer-laureatenlijst INFO [04/22/24 16:41:01:90] Skipping update of 'refs/remotes/origin/bugfix/Fastlane/FAS-419/Doorlopende_PV_Afwezigen' as it already matches the remote ref. INFO [04/22/24 16:41:01:90] Creating local branch from remote tracking 'refs/remotes/origin/fastlane/FAS-418'. INFO [04/22/24 16:41:01:97] End: Normalizing git directory for branch 'bugfix/DM-137-eind-pv-niet-getekend-waarschuwing-transfer-laureatenlijst' (Took: 1,345.72ms) ERROR [04/22/24 16:41:01:99] An unexpected error occurred: LibGit2Sharp.LibGit2SharpException: No error message has been provided by the native library at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 154 at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 172 at LibGit2Sharp.Core.Proxy.git_reference_ensure_log(RepositoryHandle repo, String refname) in //LibGit2Sharp/Core/Proxy.cs:line 2021 at LibGit2Sharp.ReferenceCollection.EnsureHasLog(String canonicalName) in //LibGit2Sharp/ReferenceCollection.cs:line 851 at LibGit2Sharp.ReferenceCollection.Add(String name, String canonicalRefNameOrObjectish, String logMessage, Boolean allowOverwrite) in //LibGit2Sharp/ReferenceCollection.cs:line 142 at LibGit2Sharp.ReferenceCollection.Add(String name, String canonicalRefNameOrObjectish, Boolean allowOverwrite) in //LibGit2Sharp/ReferenceCollection.cs:line 167 at GitVersion.ReferenceCollection.Add(String name, String canonicalRefNameOrObject, Boolean allowOverwrite) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\ReferenceCollection.cs:line 14 at GitVersion.GitPreparer.CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(String remoteName) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 347 at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 165 at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134 at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69 at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48 at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43 at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66 INFO [04/22/24 16:41:01:99] Attempting to show the current git graph (please include in issue): INFO [04/22/24 16:41:01:99] Showing max of 100 commits INFO [04/22/24 16:41:02:20] * 6ebcabde1 in the future (HEAD -> bugfix/DM-137-eind-pv-niet-getekend-waarschuwing-transfer-laureatenlijst, origin/bugfix/DM-137-eind-pv-niet-getekend-waarschuwing-transfer-laureatenlijst, refs/pipelines/39731)

6b051db48 7 minutes ago (refs/pipelines/39730) |\ | 3292dbb7e 23 minutes ago (refs/pipelines/39728) | a7a63df52 8 minutes ago |/ 97ad1b101 37 minutes ago (refs/pipelines/39726) 1343cf873 74 minutes ago (refs/pipelines/39725) 3e92b1153 77 minutes ago (refs/pipelines/39724) bfedc8d4f 85 minutes ago (refs/pipelines/39723) 0c0a9ebd3 2 hours ago (refs/pipelines/39722) a0e4357b3 2 hours ago (refs/pipelines/39721) 82fd249e4 2 hours ago (refs/pipelines/39720) 717c7ba17 3 days ago (refs/pipelines/39694) | 07e0f8b6b 3 days ago (origin/fastlane/FAS-418, refs/pipelines/39693) | 28ea8fc98 3 days ago (refs/pipelines/39678) | | 518eb1f6f 3 days ago (origin/master, refs/pipelines/39687, master) | | |\ | | | dc2b2a401 3 days ago | | |/ | | 7daea2641 3 days ago (refs/pipelines/39675) | | |\ | | | 62f600e97 3 days ago | |_|/ |/| | | | 688901da8 3 days ago (refs/pipelines/39673) | | |\ | |/ / |/| | | | ffd344e40 4 days ago (refs/pipelines/39619, fastlane/bugfix/FAS-420-send-cancellation-email) | |/ | 22c228572 4 days ago (refs/pipelines/39632) |\ \ | | 687c925c2 4 days ago |/ / | 94db4eea2 4 days ago (refs/pipelines/39606) |\ \ | | 51db344f8 4 days ago | |/ | fd8464df8 4 days ago (refs/pipelines/39605) |\ \ | |/ |/| | 126a3605a 4 days ago |/ | be2d7e0fc 3 days ago (refs/pipelines/39672, fastlane/feature/FAS-411-fastlane-cv-snashot) | 7a89ec746 4 days ago (refs/pipelines/39644) | 0af496fcd 4 days ago (refs/pipelines/39640) | 3453dc393 5 days ago (refs/pipelines/39601) | 17021b321 2 weeks ago (refs/pipelines/39308) | |\ | | 8268c75c2 2 weeks ago (refs/pipelines/39306) | | | f78e5ff82 4 days ago (refs/pipelines/39609, bugfix/DM-202-pop-up-uitzondering-addendum-doorlopend-pv) | |_|/ |/| | | | 13f9e7ee4 6 days ago (refs/pipelines/39558) |\ \ \ | | | bbc574bbc 3 weeks ago (refs/pipelines/39264, fastlane/FAS-412/GermanMails) | | | | 3fb9cecad 4 days ago (refs/pipelines/39604, feature/DM-193-eind-pv-selectie-niet-meer-doorsturen) | | | | 948c453cc 5 days ago (refs/pipelines/39597) | |||/ |/| | | | | | | d94de0990 5 days ago (refs/pipelines/39595, bugfix/final-pv-remove-not-approvable) | |||/ |/| | | | | | 85c079857 7 days ago (refs/pipelines/39508) |\ \ \ \ | | | | ad3cff411 7 days ago |/ / / / | | | | 2c6320ef2 7 days ago (refs/pipelines/39493, bugfix/DM-170-wording-addendum) | |||/ |/| | | | | | | fde612725 7 days ago (origin/feature/NServiceBusUpgrade, refs/pipelines/39483, feature/NServiceBusUpgrade) | | | | |\ | |||_|/ |/| | | | | | | | 5cfb2094a 10 days ago (refs/pipelines/39471) |\ \ \ \ \ | | | | | dd54e34ae 10 days ago |/ / / / / | | | | e4a0312c5 4 weeks ago | | | | 0499c0d71 4 weeks ago | | | | |\ | | | ||/ | | |/| | | | | | 9db931ef8 4 weeks ago | | | | |\ | | | | | 673179b49 4 weeks ago | | | | | eb9e2a04d 4 weeks ago | | | | | 493e69536 4 weeks ago | | | | | d6e14e982 4 weeks ago | | | | | 995df6b07 4 weeks ago | | | | | 26b87bdad 4 weeks ago | | | | | e4e373c08 4 weeks ago | | | | | 6466eeb39 4 weeks ago | | | | | 2fd09b306 4 weeks ago | | | | | 57065b101 4 weeks ago | | | | | 396a73642 4 weeks ago | | | | | 9e86e5204 4 weeks ago | | | | | e7486f0b1 4 weeks ago | | | | | 9e1d010c2 4 weeks ago | | | | | c898d57ba 4 weeks ago | | | | | b9f862b90 4 weeks ago | | | | | b3ae1a974 4 weeks ago | | | | | 4b5e208d3 4 weeks ago | | | | | 9c6d6b4a2 4 weeks ago | | | | | a3040a8a0 4 weeks ago | | | | | 29c024d1c 4 weeks ago | | | | |\ \ | | | | \ \ 413e8d4d0 7 weeks ago | | | | |\ \ \ | | | | \ \ \ 581063cb9 9 weeks ago | | | | |\ \ \ \ | | | | | | | | bf6d477ce 9 weeks ago | | | | | | | | 63f14cfe0 9 weeks ago | | | | |\ \ \ \ \ | | | | | | | | | fb62a267b 9 weeks ago | | | | | | | | | 10522291a 4 months ago | | | | | | | | | | 048394bac 10 days ago (refs/pipelines/39468, bugfix/DM-185-knop-aanpassen-link-screeningsmap) | |||||||||/ |/| | | | | | | | | | | | | | | | | | 7d1f9aaa6 11 days ago (refs/pipelines/39432) |\ \ \ \ \ \ \ \ \ \ | * | | | | | | | | | b07ac90d6 2 weeks ago (refs/pipelines/39341) | | ||/ / / / / / / | |/| | | | | | | | | | | | | | | | | 0c9a48554 11 days ago |/ / / / / / / / / | | | | | | | | b65e8d734 3 weeks ago (refs/pipelines/39265) |\ \ \ \ \ \ \ \ \ | |/ / / / / / / / |/| | | | | | | | | | | | | | | | fd1429bca 3 weeks ago |/ / / / / / / / | | | | | | | | 17cf22e37 3 weeks ago (refs/pipelines/39263, feature/DM-192-status-rejected-error) | | | | | | | | b5ec0f003 3 weeks ago (refs/pipelines/39262) | | | | | | | | 2148d3252 3 weeks ago (refs/pipelines/39260) | | | | | | | | c4fc0e985 3 weeks ago (refs/pipelines/39232) | | | | | | | | | c65ff2c57 3 weeks ago (origin/bugfix/Fastlane/FAS-419/Doorlopende_PV_Afwezigen, refs/pipelines/39257, bugfix/Fastlane/FAS-419/Doorlopende_PVAfwezigen) | ||||||||/ |/| | | | | | | | | | | | | | | | 3e315a95e 3 weeks ago (refs/pipelines/39209) |\ \ \ \ \ \ \ \ \ | |||||||_|/ |/| | | | | | | | | | | | | | | | e3992e20d 3 weeks ago | | | | | | | | c4ff0c43a 3 weeks ago (refs/pipelines/39208) |\ \ \ \ \ \ \ \ \ | |/ / / / / / / / |/| | | | | | | | | | | | | | | | ae7b4e317 3 weeks ago | | | | | | | | | 88cb92e32 3 weeks ago (refs/pipelines/39206, fastlane/FAS-417/EditWordingMail) | | | | | | | | | |\ | |||||||||/ |/| | | | | | | | | | | | | | | | | | b9f580cd1 3 weeks ago (refs/pipelines/39192) |\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | abb33e5d4 3 weeks ago (refs/pipelines/39191, fastlane/FAS-412/Toevoegen_Duitse_vertaling_mails) |/ / / / / / / / / / | | | | | | | | | ef2ad20a9 4 weeks ago (refs/pipelines/39165) |\ \ \ \ \ \ \ \ \ \ | |/ / / / / / / / / |/| | | | | | | | | | | | | | | | | | 19489674b 4 weeks ago |/ / / / / / / / / | | | | | | | | 1bf9cd055 3 weeks ago (refs/pipelines/39205) | |||||||/ |/| | | | | | | | | | | | | | | 239467871 4 weeks ago (refs/pipelines/39161, bugfix/Fastlane/FAS-413/Mail_geslaagd_laatsteproef) | | | | | | | | |\ | ||||||||/ |/| | | | | | | | | | | | | | | | a7436f870 4 weeks ago | | | | | | | | c5e0ad90a 4 weeks ago | | | | | | | | |\ | | | | | | | | |/ | | | | | | | |/| | | | | | | | | acd8879ee 4 weeks ago | | | | | | | | * be3bd3f8b 4 weeks ago | | | | | | | | |\ build: Version: SimpleExec.NonZeroExitCodeException: The command exited with code 1. at SimpleExec.ProcessExtensions.Throw(Process process) at SimpleExec.Command.Run(String name, String args, String workingDirectory, Boolean noEcho, String windowsName, String windowsArgs, String echoPrefix, Action1 configureEnvironment) at build.Steps.VersionStep.<>c.b__1_0() in G:\bosa-gitlab-runner\builds\D24jcpjs\0\dg-r_o\selection\selor-business\build\Steps\VersionStep.cs:line 18 at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Bullseye.Internal.ActionTarget.RunAsync(Boolean dryRun, Boolean parallel, Logger log, Func2 messageOnly) build: Version: Failed! The command exited with code 1. (1.93 s) build: ────────────────────────────────────────────────── build: Duration Outcome Target build: ───────────────── ───────── ──────────────────── build: Succeeded Tools build: 1.93 s 13,0% Failed! Version build: 2.34 s 15,7% Succeeded Nuget Tools build: 10.63 s 71,3% Succeeded NetCore Global Tools build: ├─4.19 s ├─28,1% Succeeded Octopus.DotNet.Cli build: └─6.43 s └─43,2% Succeeded GitVersion.Tool build: ────────────────────────────────────────────────── build: Failed! (job_build) (14.9 s) Running after_script 00:01 Running after script... $ git config --local core.longpaths true $ git clean -d -f -x -q -e artifacts/ Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit status 1

What is expected?

the dotnet-gitversion command also succeeding when the strategy is clone. Or find out why it is giving this error.

Steps to Reproduce

Not sure. We have a big project +-120 csproj. Which are build via a gitlab pipeline. I'm not sure if its reproducable with any project.

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

No response

HHobeck commented 5 months ago

Hi @hephie, Please provide steps to reproduce.

hephie commented 3 months ago

Hi,

The only thing I can say is, this only seems to occur when we work on a branch from master. New commits on master happen New commits on the branch happen.

After max 2 weeks a merge request is created to integrate the new code into master. But even the before the merge request is created, the automatic build pipeline that runs on the branch, gives this error.

I dont know if this is enough information?

Thomas

HHobeck commented 1 month ago

Please migrate your pipeline to the new version of git version 6.0.1. If this error persists, please create a new ticket.

Thank you!