Sdk: dotnet restore (OSX)

Created on 1 Feb 2016  路  16Comments  路  Source: dotnet/sdk

dotnet new 
dotnet restore

error: The type initializer for 'System.Net.Http.CurlHandler' threw an exception.

While this seems related to Curl, I also get an error in REPL

Console.WriteLine("Hello");
System.TypeInitializationException: The type initializer for 'Crypto' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)
   at Interop.Crypto.GetMaxMdSize()
   at Interop.Crypto..cctor()
   --- End of inner exception stack trace ---
   at Interop.Crypto.EvpSha1()
   at Internal.Cryptography.HashProviderDispenser.CreateHashProvider(String hashAlgorithmId)
   at System.Security.Cryptography.SHA1.Implementation..ctor()
   at System.Security.Cryptography.SHA1.Create()
   at Roslyn.Utilities.SHA1CryptoServiceProvider..ctor()
   at Microsoft.CodeAnalysis.CryptographicHashProvider.ComputeSha1(Byte[] bytes)
   at Microsoft.CodeAnalysis.AssemblyIdentity.CalculatePublicKeyToken(ImmutableArray`1 publicKey)
   at Microsoft.CodeAnalysis.AssemblyIdentity.get_PublicKeyToken()
   at Microsoft.CodeAnalysis.DesktopAssemblyIdentityComparer.Port(AssemblyIdentity identity)
   at Microsoft.CodeAnalysis.DesktopAssemblyIdentityComparer.ApplyUnificationPolicies(AssemblyIdentity& reference, AssemblyIdentity& definition, AssemblyIdentityParts referenceParts, Boolean& isDefinitionFxAssembly)
   at Microsoft.CodeAnalysis.AssemblyIdentityComparer.Compare(AssemblyIdentity reference, String referenceDisplayName, AssemblyIdentity definition, Boolean& unificationApplied, Boolean ignoreVersion)
   at Microsoft.CodeAnalysis.CommonReferenceManager`2.ResolveMissingAssembly(AssemblyIdentity referenceIdentity, PortableExecutableReference peReference, MetadataImportOptions importOptions, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CommonReferenceManager`2.ResolveAndBindMissingAssemblies(TCompilation compilation, ImmutableArray`1 explicitAssemblies, ImmutableArray`1 explicitModules, ImmutableArray`1 explicitReferences, ImmutableArray`1 explicitReferenceMap, MetadataReferenceResolver resolver, MetadataImportOptions importOptions, Boolean supersedeLowerVersions, ArrayBuilder`1 referenceBindings, Dictionary`2 assemblyReferencesBySimpleName, ImmutableArray`1& allAssemblies, ImmutableArray`1& metadataReferences, ImmutableArray`1& resolvedReferences, DiagnosticBag resolutionDiagnostics)
   at Microsoft.CodeAnalysis.CommonReferenceManager`2.Bind(TCompilation compilation, ImmutableArray`1 explicitAssemblies, ImmutableArray`1 explicitModules, ImmutableArray`1 explicitReferences, ImmutableArray`1 explicitReferenceMap, MetadataReferenceResolver resolverOpt, MetadataImportOptions importOptions, Boolean supersedeLowerVersions, Dictionary`2 assemblyReferencesBySimpleName, ImmutableArray`1& allAssemblies, ImmutableArray`1& implicitlyResolvedReferences, ImmutableArray`1& implicitlyResolvedReferenceMap, DiagnosticBag resolutionDiagnostics, Boolean& hasCircularReference, Int32& corLibraryIndex)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ReferenceManager.CreateAndSetSourceAssemblyFullBind(CSharpCompilation compilation)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ReferenceManager.CreateSourceAssemblyForCompilation(CSharpCompilation compilation)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.BindScriptClass()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetEntryPointAndDiagnostics(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetEntryPoint(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonGetEntryPoint(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.ScriptBuilder.Build[T](Compilation compilation, DiagnosticBag diagnostics, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.ScriptBuilder.CreateExecutor[T](ScriptCompiler compiler, Compilation compilation, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Script`1.GetExecutor(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Script`1.CommonCompile(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineRunner.TryBuildAndRun(Script`1 newScript, InteractiveScriptGlobals globals, ScriptState`1& state, ScriptOptions& options, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineRunner.RunInteractiveLoop(ScriptOptions options, String initialScriptCodeOpt, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineRunner.RunInteractiveCore(ErrorLogger errorLogger)
   at Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineRunner.RunInteractive()
   at Microsoft.CodeAnalysis.CSharp.Scripting.Hosting.Csi.Main(String[] args)

Any ideas?

Most helpful comment

Looks like this fixes the issue:

brew update
brew install openssl
brew link --force openssl

Credit goes to @davidfowl

All 16 comments

you should also log this in dotnet/corefx may be its a problem in Curl.

I am seeing the same issue:

xxxxxxxxxx:SignalR-SqlServer Administrator$ cat /usr/local/share/dotnet/cli/.version
1e45e35d2070b50b7a51adea96a5158f7b49dc9d
1.0.1.001200
xxxxxxxxxx:SignalR-SqlServer Administrator$ dotnet restore
error: The type initializer for 'System.Net.Http.CurlHandler' threw an exception.

Verbose tracing

xxxxxxxxxx:SignalR-SqlServer Administrator$ dotnet restore -v Debug
trace: Running restore with 4 concurrent jobs.
trace: Reading project file /Users/Administrator/source/SignalR-SqlServer/src/Microsoft.AspNetCore.SignalR.SqlServer/project.json.
trace: Reading project file /Users/Administrator/source/SignalR-SqlServer/test/Microsoft.AspNetCore.SignalR.SqlServer.Tests/project.json.
trace: Loaded project Microsoft.AspNetCore.SignalR.SqlServer.Tests from /Users/Administrator/source/SignalR-SqlServer/test/Microsoft.AspNetCore.SignalR.SqlServer.Tests/project.json.
trace: Loaded project Microsoft.AspNetCore.SignalR.SqlServer from /Users/Administrator/source/SignalR-SqlServer/src/Microsoft.AspNetCore.SignalR.SqlServer/project.json.
trace: Found project root directory: /Users/Administrator/source/SignalR-SqlServer.
trace: Found project root directory: /Users/Administrator/source/SignalR-SqlServer.
error: The type initializer for 'System.Net.Http.CurlHandler' threw an exception.
trace: System.AggregateException: One or more errors occurred. (The type initializer for 'System.Net.Http.CurlHandler' threw an exception.) ---> System.TypeInitializationException: The type initializer for 'System.Net.Http.CurlHandler' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Http' threw an exception. ---> System.TypeInitializationException: The type initializer for 'HttpInitializer' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)
   at Interop.CryptoInitializer.EnsureOpenSslInitialized()
   at Interop.CryptoInitializer..cctor()
   --- End of inner exception stack trace ---
   at Interop.CryptoInitializer.Initialize()
   at Interop.HttpInitializer..cctor()
   --- End of inner exception stack trace ---
   at Interop.HttpInitializer.Initialize()
   at Interop.Http..cctor()
   --- End of inner exception stack trace ---
   at Interop.Http.GetCurlVersionInfo(Int32& age, Boolean& supportsSsl, Boolean& supportsAutoDecompression, Boolean& supportsHttp2Multiplexing)
   at System.Net.Http.CurlHandler..cctor()
   --- End of inner exception stack trace ---
   at System.Net.Http.CurlHandler..ctor()
   at NuGet.Protocol.Core.v3.FactoryExtensionsV2.<>c.<GetCoreV3>b__2_7()
   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Lazy`1.LazyInitValue()
   at NuGet.Protocol.Core.Types.SourceRepository.<>c.<Init>b__12_0(Lazy`1 p)
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`3.GetEnumerator()
   at NuGet.Protocol.Core.Types.SourceRepository.Init(IEnumerable`1 providers)
   at NuGet.Protocol.Core.Types.SourceRepository..ctor(PackageSource source, IEnumerable`1 providers)
   at NuGet.CommandLine.XPlat.Program.<>c.<GetSources>b__13_3(PackageSource source)
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.<DistinctIterator>d__68`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at NuGet.CommandLine.XPlat.Program.<ExecuteRestoreAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at NuGet.CommandLine.XPlat.Program.<>c__DisplayClass7_2.<<Main>b__2>d.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.XPlat.Program.<>c__DisplayClass7_2.<<Main>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.XPlat.Program.<CompleteTaskAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at NuGet.CommandLine.XPlat.Program.<>c__DisplayClass7_1.<<Main>b__1>d.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Microsoft.Dnx.Runtime.Common.CommandLine.CommandLineApplication.Execute(String[] args)
   at NuGet.CommandLine.XPlat.Program.Main(String[] args)
---> (Inner Exception #0) System.TypeInitializationException: The type initializer for 'System.Net.Http.CurlHandler' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Http' threw an exception. ---> System.TypeInitializationException: The type initializer for 'HttpInitializer' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)
   at Interop.CryptoInitializer.EnsureOpenSslInitialized()
   at Interop.CryptoInitializer..cctor()
   --- End of inner exception stack trace ---
   at Interop.CryptoInitializer.Initialize()
   at Interop.HttpInitializer..cctor()
   --- End of inner exception stack trace ---
   at Interop.HttpInitializer.Initialize()
   at Interop.Http..cctor()
   --- End of inner exception stack trace ---
   at Interop.Http.GetCurlVersionInfo(Int32& age, Boolean& supportsSsl, Boolean& supportsAutoDecompression, Boolean& supportsHttp2Multiplexing)
   at System.Net.Http.CurlHandler..cctor()
   --- End of inner exception stack trace ---
   at System.Net.Http.CurlHandler..ctor()
   at NuGet.Protocol.Core.v3.FactoryExtensionsV2.<>c.<GetCoreV3>b__2_7()
   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Lazy`1.LazyInitValue()
   at NuGet.Protocol.Core.Types.SourceRepository.<>c.<Init>b__12_0(Lazy`1 p)
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`3.GetEnumerator()
   at NuGet.Protocol.Core.Types.SourceRepository.Init(IEnumerable`1 providers)
   at NuGet.Protocol.Core.Types.SourceRepository..ctor(PackageSource source, IEnumerable`1 providers)
   at NuGet.CommandLine.XPlat.Program.<>c.<GetSources>b__13_3(PackageSource source)
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.<DistinctIterator>d__68`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at NuGet.CommandLine.XPlat.Program.<ExecuteRestoreAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at NuGet.CommandLine.XPlat.Program.<>c__DisplayClass7_2.<<Main>b__2>d.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.XPlat.Program.<>c__DisplayClass7_2.<<Main>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.XPlat.Program.<CompleteTaskAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at NuGet.CommandLine.XPlat.Program.<>c__DisplayClass7_1.<<Main>b__1>d.MoveNext()<---

Darwin xxxxxxxxxx 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64

curl is installed and dotnet restore worked with previous versions:

xxxxxxxxxx:SignalR-SqlServer Administrator$ curl --version
curl 7.43.0 (x86_64-apple-darwin15.0) libcurl/7.43.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets

Looks like this fixes the issue:

brew update
brew install openssl
brew link --force openssl

Credit goes to @davidfowl

There's a warning in the pkg installer about the openssl dependency since https://github.com/dotnet/cli/pull/880:

image

@akoeplinger - I get my cli using the obtain script from the cli repo or indirectly when building aspnet repos so I have no chance of seeing this screen. I was not aware of the very recent move to a higherversion of openssl - the build worked fine last week.

@moozzyk yep, maybe the cli should do some basic checks to see if the dependencies are there.

@seesharper the higher version of libssl should solve the issue. Closing this, if it still repros please reopen.

Hit this today - I think that installer warning should be much stronger since you're going to hit issues with https:// feeds very quickly.

And after installing openssl, you may also need to add soft links:

brew link --force openssl

Refer to https://www.microsoft.com/net/core#macosx

And after installing openssl, I run this command brew link --force openssl encounter the error:


Terminal.app

brew link --force openssl
Linking /usr/local/Cellar/openssl/1.0.2h_1...
Error: Could not symlink share/man/man3/ASN1_OBJECT_free.3ssl
/usr/local/share/man/man3 is not writable.
localhost:dotnet gongcen$


I am trying this document to resolve this problem.

http://stackoverflow.com/questions/29319378/cant-link-pcre-thru-brew-in-max-os-yosemite

By design Homebrew (brew) requires the contents of /usr/local to be owned by you. You can fix it easily by running:

sudo chown -R `whoami` /usr/local

from your Terminal.

@moozzyk is there a way to add soft links to openssl using MacPorts instead of HomeBrew?

@asteinberger I guess it does not matter how you get the libs as long as the dynamic linker is able to find and load the required version.

Anyone running into this?

Warning: Refusing to link: openssl

@onionhammer yes, that is the new brew behavior. The instructions on https://dot.net/core have been updated with a workaround.

Thanks, that worked

@blackdwarf the page has no the instructions anymore :/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joffreykern picture joffreykern  路  3Comments

noelitoa picture noelitoa  路  3Comments

srayuws picture srayuws  路  3Comments

natemcmaster picture natemcmaster  路  3Comments

krwq picture krwq  路  3Comments