Running on Linux / docker with .NET Core: Function DATAPTR_OR_NULL not found in native library libR.so
See original GitHub issueI’m using a Dockerfile which effectively does apt-get install r-base
(I have libopenblas-base
too but removing it makes no difference) then runs a .NET Core app with the latest R.NET.
As I understand it the base image is on Debian 9.
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runner
WORKDIR /app
# install R
RUN apt-get update \
&& apt-get -y install libopenblas-base r-base \
&& apt-get clean
ENV R_HOME /usr/lib/R
The library loads fine - if I remove /usr/lib/R/lib/libR.so
, it fails much sooner. I see the comment in the getting starting guide, about LD_LIBRARY_PATH
, but the error is the same if I set that to /usr/lib/R/lib
(init works, but the call fails).
Not sure if relevant - I’m new to this - but nm -D /usr/lib/R/lib/libR.so | grep -i data
doesn’t show a function exported from libR.so
called DATAPTR_OR_NULL
. So maybe the error is telling the truth?
The code is based on the sample repo:
var r = REngine.GetInstance();
var charVec = r.CreateCharacterVector(new[] {"Hello, R world!, .NET speaking"});
r.SetSymbol("greetings", charVec);
r.Evaluate("str(greetings)");
var a = r.Evaluate("'Hi there .NET, from the R engine'").AsCharacter().ToArray();
The error:
Function DATAPTR_OR_NULL not found in native library libR.so
at DynamicInterop.UnmanagedDll.throwEntryPointNotFound(String entryPoint)
at DynamicInterop.UnmanagedDll.GetFunction[TDelegate](String entryPoint)
at RDotNet.Vector`1.get_DataPointer()
at RDotNet.CharacterVector.SetValue(Int32 index, String value)
at RDotNet.CharacterVector.SetVectorDirect(String[] values)
at RDotNet.Vector`1.SetVector(T[] values)
at RDotNet.REngineExtension.CreateCharacterVector(REngine engine, IEnumerable`1 vector)
at Ambilytics.Endpoints.System.RTestEndpoint.<>c.<Handle>b__0_0() in /app/Endpoints/System/RTestEndpoint.cs:line 26
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at Ambilytics.Endpoints.System.RTestEndpoint.Handle() in /app/Endpoints/System/RTestEndpoint.cs:line 23
Note, the code runs fine on Windows.
I see here a list of functions: https://github.com/rdotnet/rdotnet/blob/ff006e13c167a4a7d1dfa5e0c25059b2b8fb4260/R.NET/Internals/Delegates.cs - looking at the last few (ALL CAPS) ones, they don’t seem to be present in libR.so
? Looking at the other functions listed there, they do seem to exist in the .so… And I can see DATAPTR_OR_NULL
export does exist on R.dll on Windows.
I also see that these functions came in here - https://github.com/rdotnet/rdotnet/commit/d935049274d712ae3caa7aadf2689feeecfe0d8b (“Fixed indexing ALTREP integer vectors”)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top GitHub Comments
In case anyone else finds it useful, there’s an .NET Core runtime-with-latest-R docker image:
https://github.com/RedRiverSoftware/dockerhub/tree/master/aspnet-runtime-with-r https://hub.docker.com/r/redriversoftware/aspnet-runtime-with-r
@kierenj sorry again about this issue. “Root cause” was lack of testing on Linux on my part - I can see now that it’s not able to complete the check to see if it should use the ALTREP, and defaults to assuming it should use ALTREP (https://github.com/rdotnet/rdotnet/blob/master/R.NET/REngine.cs#L278-L281). I need to get this set up to properly determine version on Linux. I have a test environment set up to verify once a fix is in place.