ektrah/libsodium-core

unable to load shared library 'libsodium' or one of its dependencies while running on Linux based systems

Closed this issue · 10 comments

Sodium.Core version 1.2.3
While running on Windows it works well but as soon as it is deployed to Linux it starts to give the following error:
`[2021-09-30T07:05:22.861Z] Executed 'Function1' (Failed, Id=7297ab58-446c-4d58-963d-be8a3f493646, Duration=14084ms)

[2021-09-30T07:05:22.861Z] System.Private.CoreLib: Exception while executing function: Function1. Sodium.Core: Unable to load shared library 'libsodium' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibsodium: cannot open shared object file: No such file or directory.

`
How to reproduce, an uncomplicated way:
create a simple func app using Visual studio template or create a simple console app.
Run on windows and validate it works just fine--all libs can be loaded

Add docker support so it runs on mcr.microsoft.com/azure-functions/dotnet:3.0 image (default in vs studio)
run again. note that that docker consol outputs error similar to above one.

Issue first discovered by running azure func app on linux based price plan.

Could you provide the output of dotnet --info from within the mcr.microsoft.com/azure-functions/dotnet:3.0 container?

@ektrah
I tried on both image and azure app service plan ssh consol but seems that in both places dotnet executable is either is not in the path or not present at all (or used in other way like starting from .dll file. so I am unable to produce the output.

not sure if it helps but libsodium lib seems to be present
image

What Linux distribution and version and what CPU architecture are you using?

I think there are two things that could possibly go wrong here: (1) libsodium.so cannot be found by the application; (2) libsodium.so can be found but cannot be loaded. (Both result in the same exception.) To find out which one it is, I'd try doing what the exception message says and debug the problem using the LD_DEBUG environment variable.

@ektrah
do you know why in error message it is spelled like "liblibsodium"?

in docker it is:
root@2c8dfdacf9fb:/home/site/wwwroot# uname -a
Linux 2c8dfdacf9fb 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 GNU/Linux

do you know why in error message it is spelled like "liblibsodium"?

If .NET Core cannot find or load a library, it tries again with "lib" before the library name, just in case that happens to work. If it cannot find or load a library even with "lib" before the name, it raises an exception. The exception message then is a bit confusing but nothing to worry about.

in docker it is:
root@2c8dfdacf9fb:/home/site/wwwroot# uname -a
Linux 2c8dfdacf9fb 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 GNU/Linux

That unfortunately doesn't tell me what I'm looking for. You could try installing the .NET Core SDK in the container and then run dotnet --info. I guess at the end only debugging the problem using LD_DEBUG will give certainty, though.

after a few more experiments I have reported this issue here:
https://github.com/Azure/azure-functions-core-tools/issues/2737

my intermediate solution is:
change how function zip file is produced by copying libsodium.so file to bin folder in a pipeline for Linux builds.