Hi,
I am using Alpine docker image for my nodejs application. I have added libLexActivator.so to application bundle but it fails to load with below error.
(node:7) UnhandledPromiseRejectionWarning: Error: Dynamic Linking Error: Error relocating ./libLexActivator.so: __rawmemchr: symbol not found
Does lexActivator supports usage in alpine linux? Please guide me on how to use libLexActivator.so in alpine.
Thanks!
Hi Mathew,
Alpine uses a different C library. Please find the custom build files for Alpine below:
Thanks!! Let me use this library and see.
Hi,
I am getting below error while using the above custom build shared to me
(node:6) UnhandledPromiseRejectionWarning: Error: Dynamic Symbol Retrieval Error: Symbol not found: GetLicenseMeterAttribute.
Please have a look.
Thanks!
Hi Mathew,
Please find attached the updated image.
shane
June 10, 2020, 9:26pm
6
Is there a plan to roll this into an official release? We are also trying to use Cryptlex in an environment which is using a .net Core application inside of an Alpine Linux docker image. At runtime, it does not find the required shared lib.
Hi Shane,
This has been part of the official build for a long time now. When you download LexActivator lib from dashboard, it contains a separate folder for musl (Alpine).
It is also included in the dotnet nuget package.
There seems to be issue with dotnet. It is loading the wrong .so file.
opened 04:07PM - 12 Nov 18 UTC
closed 05:31AM - 31 Jan 20 UTC
area-Interop-coreclr
_From @rjsathome on November 12, 2018 11:54_
I have a nuget package containing … native code which is called via p/invoke fromt the .NET Core assembly.
When using this on Alpine Linux I get:
```sh
vmalpine64 (1)$ dotnet run
Using launch settings from /home/rjs/src/pdflib-9.1.x/dist/PDFlib/PDFlib-9.1.2p8-Alpine-Linux-x86_64-.NET-Core/bind/dotnetcore/csharp/hello/Properties/launchSettings.json...
Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'PDFlib_dotnetcore_native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libPDFlib_dotnetcore_native: No such file or directory
at PDFlib_dotnet.PDFlib.PInvoke.PDF_new()
at PDFlib_dotnet.PDFlib..ctor()
at Hello.Main(String[] args) in /home/rjs/src/pdflib-9.1.x/dist/PDFlib/PDFlib-9.1.2p8-Alpine-Linux-x86_64-.NET-Core/bind/dotnetcore/csharp/hello/hello.cs:line 15
```
The minmal code to reproduce is:
```csharp
using PDFlib_dotnet;
class Hello {
static void Main(string[] args) {
PDFlib p;
p = new PDFlib();
}
}
```
The Nuget package content is:
```sh
vmalpine64 (1)$ unzip -l ../../PDFlib_dotnet.1.2.8.nupkg
Archive: ../../PDFlib_dotnet.1.2.8.nupkg
Length Date Time Name
--------- ---------- ----- ----
503 11-06-2018 15:00 _rels/.rels
748 11-06-2018 15:00 PDFlib_dotnet.nuspec
35840 11-06-2018 14:00 lib/netstandard2.0/PDFlib_dotnet.dll
36 10-22-2018 18:47 readme.txt
8617128 11-06-2018 14:00 runtimes/alpine-x64/native/PDFlib_dotnetcore_native.so
582 11-06-2018 15:00 [Content_Types].xml
706 11-06-2018 15:00 package/services/metadata/core-properties/5c87229948e04d93aab4633ed8c7fcc5.psmdcp
-------- -------
8655543 7 files
```
I would expect that `dotnet run` finds the nativ library at runtimes/alpine-x64/native/PDFlib_dotnetcore_native.so in the nuget package.
When I check with strace where dotnet searches I find:
```sh
vmalpine64 (1)$ strace -f -o strace.txt dotnet run
Using launch settings from /home/rjs/src/pdflib-9.1.x/dist/PDFlib/PDFlib-9.1.2p8-Alpine-Linux-x86_64-.NET-Core/bind/dotnetcore/csharp/hello/Properties/launchSettings.json...
Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'PDFlib_dotnetcore_native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libPDFlib_dotnetcore_native: No such file or directory
at PDFlib_dotnet.PDFlib.PInvoke.PDF_new()
at PDFlib_dotnet.PDFlib..ctor()
at Hello.Main(String[] args) in /home/rjs/src/pdflib-9.1.x/dist/PDFlib/PDFlib-9.1.2p8-Alpine-Linux-x86_64-.NET-Core/bind/dotnetcore/csharp/hello/hello.cs:line 7
vmalpine64 (1)$ grep dotnetcore_native strace.txt
dotnet/runtime#852 open("/home/rjs/dotnet/shared/Microsoft.NETCore.App/2.1.2/PDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/home/rjs/.nuget/packages/pdflib_dotnet/1.2.8/lib/netstandard2.0/PDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/lib/PDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/usr/local/lib/PDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/usr/lib/PDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/home/rjs/dotnet/shared/Microsoft.NETCore.App/2.1.2/libPDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/home/rjs/.nuget/packages/pdflib_dotnet/1.2.8/lib/netstandard2.0/libPDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/lib/libPDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/usr/local/lib/libPDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/usr/lib/libPDFlib_dotnetcore_native.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/home/rjs/dotnet/shared/Microsoft.NETCore.App/2.1.2/PDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/home/rjs/.nuget/packages/pdflib_dotnet/1.2.8/lib/netstandard2.0/PDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/lib/PDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/usr/local/lib/PDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/usr/lib/PDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/home/rjs/dotnet/shared/Microsoft.NETCore.App/2.1.2/libPDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/home/rjs/.nuget/packages/pdflib_dotnet/1.2.8/lib/netstandard2.0/libPDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/lib/libPDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/usr/local/lib/libPDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
16906 open("/usr/lib/libPDFlib_dotnetcore_native", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
```
On Alpine-Linux `donet run` only looks in the "/home/rjs/.nuget/packages/pdflib_dotnet/1.2.8/lib/netstandard2.0/" directory, not int the "runtimes/alpine-x64/native/" directory.
The dotnet version is:
```sh
vmalpine64 (1)$ dotnet --version
2.1.400
````
I also tested it with the 2.1.403 version.
Alpine LInux is:
```sh
vmalpine64 (1)$ uname -a
Linux vmalpine64 4.14.69-0-vanilla dotnet/coreclr#1-Alpine SMP Mon Sep 10 19:33:23 UTC 2018 x86_64 Linux
vmalpine64 (1)$ cat /etc/alpine-release
3.8.1
````
On macOS or Ubuntu it is working as expected.
_Copied from original issue: dotnet/corefx#33409_
As a work around after dotnet build you need to copy
./bin/Debug/netcoreapp3.1/runtimes/linux-musl-x64/native/libLexActivator.so
to
./bin/Debug/netcoreapp3.1/runtimes/linux-x64/native/libLexActivator.so
shane
June 11, 2020, 6:28pm
9
We resolved it by adding curl during the docker build as its a dependency not in Alpine by default.
UnhandledPromiseRejectionWarning originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). A rejected promise is like an exception that bubbles up towards the application entry point and causes the root error handler to produce that output. It usually happens in async await functions, and there’s an easy fix.
const functionName = async (arguments) => {
try {
// Your code here
} catch (error) {
// Handle rejection here
}
};
A nice way to wait for several Promises to resolve to use the Promise.all function. It expects an Array of Promises, and produces a Promise that resolves to an Array containing the values that the individual Promises resolved to. Furthermore, it only resolves after the last Promise resolves. If any of its input Promises rejects, then the entire Promise.all expression rejects as well. It effectively “runs” all of its input processes “at the same time”, emulating the classic “fork-join” pattern.