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

Running an fsx script from "Reading and writing RData files" with fsi throws a System.Reflection.TargetInvocationException exception. #262

Open
EverybodyKurts opened this issue Jan 7, 2023 · 3 comments

Comments

@EverybodyKurts
Copy link

EverybodyKurts commented Jan 7, 2023

Describe the bug

Running an fsx script from Reading and writing RData files with fsi throws a System.Reflection.TargetInvocationException exception.

To Reproduce

Create a script that loads sample.rdata as shown in the Reading and writing RData files example:

open RProvider

type Sample = RData<"data/sample.rdata">
let sample = Sample()

// Easily access saved values
sample.volcano
sample.volcanoList
sample.volcanoMean

Run it in VSCode (with Ionide installed) via the Command Pallette via send file OR run it on the command line with the following command:

% dotnet fsi script.fsx
chmod: '/Users/mueller.128/.nuget/packages/rprovider/2.1.0/lib/net5.0/server/osx-arm64/RProvider.Server': No such file or directory
Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
  cannot open compressed file '/Users/mueller.128/.packagemanagement/nuget/Cache/sample.rdata', probable reason 'No such file or directory'


/Users/mueller.128/Developer/comrit/imrp-frontend/script.fsx(5,15): error FS3033: The type provider 'RProvider.RDataProvider' reported an error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Exception: Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection

   at RProvider.Server.EventLoop.runServerCommandSafe[a](FSharpFunc`2 f) in /Users/runner/work/RProvider/RProvider/src/RProvider.Server/RInteropServer.fs:line 78
   at RProvider.Server.RInteropServer.RProvider.Internal.IRInteropServer.GetRDataSymbols(String file) in /Users/runner/work/RProvider/RProvider/src/RProvider.Server/RInteropServer.fs:line 107
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at PipeMethodCalls.RequestHandler`1.GetTypedResponseForRequest(SerializedPipeRequest request)

Expected behavior

The script to run successfully without throwing an error.

Screenshots

Screen Shot 2023-01-07 at 4 47 35 PM

Environment (please complete the following information):

  • OS: macOS, arm64
  • OS Version: 12.6.2
  • using it in an fsx script
  • RProvider Version: 2.1.0
  • Installed R Version: 4.2.2

Additional context
Add any other context about the problem here.

@EverybodyKurts
Copy link
Author

I should note I have net7.0 installed on my machine. I noticed

<TargetFramework Condition="'$(RuntimeIdentifier)'=='osx-arm64'">net6.0</TargetFramework>
doesn't mention net7.0

@EverybodyKurts
Copy link
Author

It's also worth noting that when I run a dotnet 6 bullseye container with aarch64 hardware, rprovider tries to look in a nonexistent directory:

$ dotnet fsi script.fsx
/usr/share/dotnet/sdk/6.0.404/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "" and the processor architecture of the reference "/home/vscode/.nuget/packages/rprovider/2.1.0/lib/net5.0/RProvider.Server.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [/home/vscode/.packagemanagement/nuget/Projects/845--3c980b4e-05c9-47d3-b65d-a630fd882448/Project.fsproj]
chmod: cannot access "'/home/vscode/.nuget/packages/rprovider/2.1.0/lib/net5.0/server/linux-x64/RProvider.Server'": No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory


/home/vscode/.packagemanagement/nuget/Cache/fb9242c43856bc61aaeecc6eaf2047d16c0039d25de22f3eb2769b4aed1eb227.fsx(19,1): error FS3053: The type provider 'RProvider.RProvider' reported an error: The type provider constructor has thrown an exception: Failed to start the R.NET server within 20 seconds.To enable logging set RPROVIDER_LOG to an existing file name.

@nhirschey
Copy link
Contributor

nhirschey commented Apr 25, 2023

Looks like a possible resolution folder issue, such as needing to provide a resolution folder to CsvProvider so that it doesn't look for the file in the .nuget path. This arose with the introduction of #r nuget... and it looks like solving this would require adding a ResolutionFolder static type to the RData type provider.

See documentation of CsvProvider using ResolutionFolder.

Static parameters in RProvider:

let parameter = ProvidedStaticParameter("FileName", typeof<string>)
do
rdata.DefineStaticParameters([ parameter ], generateTypes asm)

Similar in CsvProvider defining the resolution folder can be seen here

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

No branches or pull requests

2 participants