Cake_Git icon indicating copy to clipboard operation
Cake_Git copied to clipboard

Clone test - The type initializer for 'ManagedHttpSmartSubtransportStream' threw an exception

Open savornicesei opened this issue 4 years ago • 10 comments

Hi,

I'm just running the build script on develop branch, on W10 `.\build.ps1' and I get this error on the Clone test:

========================================
Git-Clone
========================================
Cloning repo https://github.com/WCOMAB/CakeGitTestRepo.git...
An error occurred when executing task 'Git-Clone'.

----------------------------------------
Teardown
----------------------------------------
Finished running tasks.
Trying to clean up test repo D:/OSS/cake-build/upstream-Cake_Git/TestRepo
Successfully cleaned test repo D:/OSS/cake-build/upstream-Cake_Git/TestRepo
Error: One or more errors occurred.
        The type initializer for 'ManagedHttpSmartSubtransportStream' threw an exception.

Inner Exception:
    Operation is not supported on this platform.
An error occurred when executing task 'Test'.

Is there some setup required for succesfully run the net461 tests?

Thanks, Simo

savornicesei avatar Aug 19 '21 18:08 savornicesei

I can repro on a Windows 10 VM with .NET Framework 4.8 installed:

image

augustoproiete avatar Aug 19 '21 20:08 augustoproiete

Thanks for confirmation. I tried with the latest libgit2sharp but got the same error. One thing that I noticed is that libgit2sharp targets only netstandard2.0;netcoreapp2.1 but netstandard2.0 should be compatible with .net461.

savornicesei avatar Aug 19 '21 20:08 savornicesei

@savornicesei Indeed the problem is internal to libgit2sharp and will need to be fixed there. Tracking via https://github.com/libgit2/libgit2sharp/issues/1904

augustoproiete avatar Aug 19 '21 23:08 augustoproiete

Hi, I have faced with same error, what has broken? windows update?

SergeiTerentev avatar Aug 25 '21 11:08 SergeiTerentev

@SergeiTerentev Could be... The libgit2sharp team might know more details -> https://github.com/libgit2/libgit2sharp/issues/1904

augustoproiete avatar Aug 25 '21 14:08 augustoproiete

Here is workaround: #addin nuget:?package=Cake.Git&version=1.0.1 It use previous version of libgit2sharp and has no issue

SergeiTerentev avatar Aug 26 '21 07:08 SergeiTerentev

Here is workaround: #addin nuget:?package=Cake.Git&version=1.0.1 It use previous version of libgit2sharp and has no issue

Interesting previous versions don't work with newer Linux distributions and MacOS versions.

Guess the workaround could then be to pin the version with an environment variable until it's fixed upstream i.e.

#addin nuget:?package=Cake.Git&%CAKE_GIT_VERSION_OVERRIDE%

var testCloneRepo           = MakeAbsolute(Directory("./TestRepo/CloneRepo"));
var sourceUrl = "https://github.com/WCOMAB/CakeGitTestRepo.git";


if (DirectoryExists(testCloneRepo))
{
    DeleteDirectory(
        testCloneRepo,
        new DeleteDirectorySettings {
            Recursive = true,
            Force = true
        }
    );
}

Information("Cloning repo {0}...", sourceUrl);
var repo = GitClone(sourceUrl, testCloneRepo);
Information("Cloned {0}.", repo);

And then it can be overridden by an env variable like this


$ENV:CAKE_GIT_VERSION_OVERRIDE="version=1.01"
dotnet cake .\cakegit.cake

devlead avatar Aug 26 '21 07:08 devlead

But if previous versions work it's even more clear it's an upstream issue.

devlead avatar Aug 26 '21 07:08 devlead

Here is workaround: #addin nuget:?package=Cake.Git&version=1.0.1 It use previous version of libgit2sharp and has no issue

This worked for me. You just saved my life

Imperatorn avatar Sep 06 '21 13:09 Imperatorn

https://github.com/libgit2/libgit2sharp/issues/1904 has been closed as fixed in LibGit2Sharp 0.29.0

Created https://github.com/cake-contrib/Cake_Git/issues/176 to track update of Cake.Git to LibGit2Sharp 0.29.0

pascalberger avatar Dec 03 '23 21:12 pascalberger