RProvider icon indicating copy to clipboard operation
RProvider copied to clipboard

Hangs inside F# interactive --use script with R 2.15 or later

Open hmansell opened this issue 12 years ago • 2 comments

Seems like the call to R_setupMainLoop from R.NET hangs.

Works in the compiler and IDE, for some reason, though not in F# interactive.

Haven't tried compiled code.

hmansell avatar Nov 28 '12 14:11 hmansell

I did some investigation today, to get this to work with R 3.0. I discovered the following:

  • With R 3.0, unchanged versions of RDotNet and RProvider, everything works fine in compiled assemblies
  • Also works fine in the F# interactive, if the assemblies are loaded by your script
  • If you load the assemblies from a script passed as an FSI startup script with --use, then this hangs during the load of RProvider.dll. A debugger reveals that this is in the RDotNet call to setup_RmainLoop.

I have a feeling this has to do with when FSI sets up the windows event loop. I guess that it hasn't done so while running the --use script.

I have a couple of ideas for working around this:

  1. Initializing RDotNet lazily rather than at load time
  2. Investigating whether the Interactive property of the RDotNet StartupParameter class does anything to improve this. This is just a mirror of the C structure from R, which in the example of embedding R from the R documentation is set to false.

hmansell avatar Jun 12 '13 20:06 hmansell

Had no luck with either of these. I can't initialize RDotNet any more lazily than I do because the type provider has to read the list of packages in order to determine the list of namespaces it exposes.

The Interactive property had no effect.

I looked through the source of the R setupMainLoop function but didn't see anything that would obviously fail. Tried building from source to step through in the debugger but couldn't get it to build...

I am going to update the docs to reflect the true limitation rather than just restricting the version.

hmansell avatar Jun 13 '13 12:06 hmansell