Skip to content

Cake fails to load native libraries on Ubuntu 22.04 #3931

@devlead

Description

@devlead

As discovered in actions/runner-images#6029, Cake fails to load native libraries on Ubuntu 22.04

Verifying assembly 'Cake.Sonar, Version=1.1.29.0, Culture=neutral, PublicKeyToken=null'.
Error: System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory
   at Cake.Core.Polyfill.AssemblyHelper.LoadUnixLibrary(String path, Int32 flags)
   at Cake.Core.Polyfill.AssemblyHelper.LoadAssembly(ICakeEnvironment environment, IFileSystem fileSystem, FilePath path) in C:\projects\cake\src\Cake.Core\Polyfill\AssemblyHelper.cs:line 54

Will need some investigation but iIssue probably in

[DllImport("libdl", EntryPoint = "dlopen")]
private static extern IntPtr LoadUnixLibrary(string path, int flags);

Which likely should on newer distros be

[DllImport("libdl.so.2", EntryPoint = "dlopen")] 
private static extern IntPtr LoadUnixLibrary2(string path, int flags); 

we probably could have a flag for which to use, unset by default, set when successful or unset and below catch try the other and set if success, so it's a one-time runtime cost.

catch (DllNotFoundException)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions