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

.NET 5.0 apps require libc-dev #24153

Closed
gitfool opened this issue Sep 15, 2020 · 14 comments · Fixed by #24485
Closed

.NET 5.0 apps require libc-dev #24153

gitfool opened this issue Sep 15, 2020 · 14 comments · Fixed by #24485

Comments

@gitfool
Copy link
Contributor

gitfool commented Sep 15, 2020

What version of gRPC and what language are you using?

Grpc v2.24.0 via Pulumi v2.10.0 NuGet packages for .NET

What operating system (Linux, Windows,...) and version?

Ubuntu 20.04

What did you do?

Run pulumi up, which uses grpc under the hood.

What did you expect to see?

Run without error.

What did you see instead?

Diagnostics:
  pulumi:pulumi:Stack (aws-alpha):
    Unhandled exception. System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl.so: cannot open shared object file: No such file or directory
       at Grpc.Core.Internal.UnmanagedLibrary.Linux.dlopen(String filename, Int32 flags)
       at Grpc.Core.Internal.UnmanagedLibrary.LoadLibraryPosix(Func`3 dlopenFunc, Func`1 dlerrorFunc, String libraryPath, String& errorMsg) in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\UnmanagedLibrary.cs:line 163
       at Grpc.Core.Internal.UnmanagedLibrary.PlatformSpecificLoadLibrary(String libraryPath, String& errorMsg) in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\UnmanagedLibrary.cs:line 151
       at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives) in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\UnmanagedLibrary.cs:line 54
       at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary() in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\NativeExtension.cs:line 103
       at Grpc.Core.Internal.NativeExtension.LoadNativeMethods() in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\NativeExtension.cs:line 120
       at Grpc.Core.Internal.NativeExtension..ctor() in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\NativeExtension.cs:line 40
       at Grpc.Core.Internal.NativeExtension.Get() in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\NativeExtension.cs:line 65
       at Grpc.Core.Internal.NativeMethods.Get() in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\NativeMethods.cs:line 49
       at Grpc.Core.GrpcEnvironment.GrpcNativeInit() in T:\src\github\grpc\src\csharp\Grpc.Core\GrpcEnvironment.cs:line 373
       at Grpc.Core.GrpcEnvironment..ctor() in T:\src\github\grpc\src\csharp\Grpc.Core\GrpcEnvironment.cs:line 302
       at Grpc.Core.GrpcEnvironment.AddRef() in T:\src\github\grpc\src\csharp\Grpc.Core\GrpcEnvironment.cs:line 78
       at Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable`1 options) in T:\src\github\grpc\src\csharp\Grpc.Core\Channel.cs:line 70
       at Pulumi.GrpcEngine..ctor(String engine) in /home/travis/gopath/src/github.com/pulumi/pulumi/sdk/dotnet/Pulumi/Deployment/GrpcEngine.cs:line 19
       at Pulumi.Deployment..ctor() in /home/travis/gopath/src/github.com/pulumi/pulumi/sdk/dotnet/Pulumi/Deployment/Deployment.cs:line 96
       at Pulumi.Deployment.CreateRunner() in /home/travis/gopath/src/github.com/pulumi/pulumi/sdk/dotnet/Pulumi/Deployment/Deployment_Run.cs:line 161
       at Pulumi.Deployment.RunAsync[TStack]() in /home/travis/gopath/src/github.com/pulumi/pulumi/sdk/dotnet/Pulumi/Deployment/Deployment_Run.cs:line 104
       at Pharos.Gemini.Program.Main() in D:\Devel\Mps\devops-gemini-pulumi\Aws\Program.cs:line 27
       at Pharos.Gemini.Program.<Main>()

    error: an unhandled error occurred: Program exited with non-zero exit code: -1

Anything else we should know about your project / environment?

I'm using .NET 5.0 RC1. This looks like a regression of #8156.

I can work around the issue by installing libc-dev:

sudo apt update && sudo apt install -y libc-dev
@angwangiot
Copy link

Windows, publish exe by 'generate a single file', an error occurred, the path can be obtained through 'AppContext.BaseDirectory'
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.IO.Path.Combine(String path1, String path2)
at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
at Grpc.Core.Internal.NativeExtension..ctor()
at Grpc.Core.Internal.NativeExtension.Get()
at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
at Grpc.Core.GrpcEnvironment..ctor()
at Grpc.Core.GrpcEnvironment.AddRef()
at Grpc.Core.Server..ctor(IEnumerable`1 options)
at Grpc.Core.Server..ctor()

@nycdotnet
Copy link

nycdotnet commented Oct 15, 2020

Confirming this is an issue when using the recently released .NET 5 RC2 docker images (runtime and aspnet images) with gRPC 1.32.

Adding the below to our dockerfiles works around it:

# workaround for https://github.com/grpc/grpc/issues/24153
RUN apt-get update && apt-get install -y libc-dev && apt-get clean

@gitfool
Copy link
Contributor Author

gitfool commented Oct 18, 2020

This issue is due to breaking change FrameworkDescription's value is .NET instead of .NET Core in .NET 5.0. I have a fix but I've asked for feedback to make sure I'm not missing something.


@angwangiot that's a separate issue that I hit too when publishing a single-file executable for .NET 5.0. This is due to another breaking change Assembly-related API behavior changes for single-file publishing format and is coming from use of Assembly.Location in Grpc.Core.Internal.NativeExtension.GetAssemblyPath.

A fix for that may be to replace the following in Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary:

var assemblyDirectory = Path.GetDirectoryName(GetAssemblyPath());

with:

var assemblyDirectory = AppContext.BaseDirectory;

But I'm not sure how that would interact with IncludeNativeLibrariesForSelfExtract:

these files will be extracted to a temporary directory in the client machine when the single file application is run.

(from other considerations for single file deployment.)

@angwangiot
Copy link

Judging from the current.NET Core documentation, there may be a need for different processing depending on the version and release parameters.
@gitfool

@ghost
Copy link

ghost commented Dec 1, 2020

Windows, publish exe by 'generate a single file', an error occurred, the path can be obtained through 'AppContext.BaseDirectory'
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.IO.Path.Combine(String path1, String path2)
at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
at Grpc.Core.Internal.NativeExtension..ctor()
at Grpc.Core.Internal.NativeExtension.Get()
at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
at Grpc.Core.GrpcEnvironment..ctor()
at Grpc.Core.GrpcEnvironment.AddRef()
at Grpc.Core.Server..ctor(IEnumerable`1 options)
at Grpc.Core.Server..ctor()

@angwangiot did you resolve this? I am seeing this too on a .net 5.0 project publish as single exe. Everything was fine with .net core 3.1

@gitfool
Copy link
Contributor Author

gitfool commented Dec 1, 2020

@aaronhudon-ts the first order fix to .net 5.0 single file executables will be coming in the next Grpc.Core release (2.34.0).

@ghost
Copy link

ghost commented Dec 2, 2020

@aaronhudon-ts the first order fix to .net 5.0 single file executables will be coming in the next Grpc.Core release (2.34.0).

@gitfool thank you Sean - when can we expect to see this appear in Nuget?

@gitfool
Copy link
Contributor Author

gitfool commented Dec 2, 2020

@aaronhudon-ts your guess is as good as mine, but since v1.34.0 was tagged today (NuGet package uses version+1), I'll be hitting refresh on https://www.nuget.org/packages/Grpc.Core every day. 😉

@jtattermusch
Copy link
Contributor

@aaronhudon-ts the first order fix to .net 5.0 single file executables will be coming in the next Grpc.Core release (2.34.0).

FTR #24744 is the PR that fixed that.

@jtattermusch
Copy link
Contributor

@aaronhudon-ts your guess is as good as mine, but since v1.34.0 was tagged today (NuGet package uses version+1), I'll be hitting refresh on https://www.nuget.org/packages/Grpc.Core every day. 😉

The 2.34.0 nugets are currently being uploaded, so you can increase the frequency of hitting https://www.nuget.org/packages/Grpc.Core now :-) It would be nice if you could confirm that things are working well for you now.

@ghost
Copy link

ghost commented Dec 3, 2020

@aaronhudon-ts your guess is as good as mine, but since v1.34.0 was tagged today (NuGet package uses version+1), I'll be hitting refresh on https://www.nuget.org/packages/Grpc.Core every day. 😉

The 2.34.0 nugets are currently being uploaded, so you can increase the frequency of hitting https://www.nuget.org/packages/Grpc.Core now :-) It would be nice if you could confirm that things are working well for you now.

I snagged it this morning and integrated the new version with our Blazor project. Publishes to single-exe works now! Thank you for getting this fixed so quickly!

@gitfool
Copy link
Contributor Author

gitfool commented Dec 3, 2020

@aaronhudon-ts good to know! Could you please also try your scenario with the IncludeNativeLibrariesForSelfExtract option?

@gitfool
Copy link
Contributor Author

gitfool commented Dec 7, 2020

I did a test with Grpc.Core version 2.34.0 and it works for IncludeNativeLibrariesForSelfExtract too! 😀

@HarryPi
Copy link

HarryPi commented Mar 17, 2021

Just want to leave a comment for anyone who happens to reach here with the same error. I had the same error while using Firestore 2.3 which implicitly required Grpc.Core, but as soon as i explicitly referenced Grpc.Core ( in my case 2.36.1 ) in my .csproj this worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants