Skip to content

Can't use RProvider in fsdocs --eval mode #268

@AndrewIOM

Description

@AndrewIOM

Describe the bug
When trying to use RPRrovider from a .fsx file in an fsdocs docs project,

To Reproduce
Steps to reproduce the behavior:

  1. Start a new fsdocs project.
  2. Add a script with the below content.
  3. Run script in dotnet fsi, then run in dotnet fsdocs watch.
(**
---
title: RProvider test
category: RProvider test
categoryindex: 1
index: 1
---
*)

#r "nuget:RProvider"

open RProvider
open RProvider.Operators
open RDotNet

try
    // R.pi |> ignore
    R.``+``([ 1.; 2. ]) |> ignore
    // R.abs(1.) |> ignore
    // printfn "%A" <| RProvider.datasets.R.volcano.GetValue<string>()
with
    | (e:exn) -> 
        printfn "Exception thrown: %s" e.Message
        printfn "Trace was: %s" e.StackTrace
(*** include-fsi-merged-output ***)

Expected behavior
The script should return the same html string in both dotnet fsi and dotnet fsdocs watch.

Environment (please complete the following information):

  • OS: macOS
  • OS Version: Sonoma
  • Using in script or library: fsdocs
  • RProvider Version 2.1.0
  • Installed R Version 4.1.1

Additional context
The exception thrown is as follows:

System.ComponentModel.Composition APIs are not supported on this platform.
seq []
   at System.ComponentModel.Composition.Primitives.ComposablePartCatalog..ctor()
   at System.ComponentModel.Composition.Hosting.DirectoryCatalog..ctor(String path, String searchPattern)
   at RProvider.RInteropInternal.catalogs@114.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl() in D:\a\_work\1\s\src\FSharp.Core\seqcore.fs:line 488
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at RProvider.RInteropInternal.mefContainer@99.Invoke(Unit unitVar)
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
   at System.Lazy`1.CreateValue()
   at RProvider.RInteropInternal.tryGetConverter@158-1.Invoke(Type vt)
   at Microsoft.FSharp.Collections.SeqModule.TryPick[T,TResult](FSharpFunc`2 chooser, IEnumerable`1 source) in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 804
   at RProvider.RInteropInternal.convertToR[inType](REngine engine, inType value)
   at RProvider.RInteropInternal.REngine.SetValue(REngine this, Object value, FSharpOption`1 symbolName)
   at RProvider.RInteropInternal.toR(Object value)
   at RProvider.RInterop.passArg@604(List`1 tempSymbols, Object arg)
   at RProvider.RInterop.argList@630-1.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl() in D:\a\_work\1\s\src\FSharp.Core\seqcore.fs:line 488
   at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable`1 source) in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 1027
   at RProvider.RInterop.callFunc(String packageName, String funcName, IEnumerable`1 argsByName, Object[] varArgs)
   at <StartupCode$FSI_0025>.$FSI_0025.main@()

It works with R.pi or R.abs(1.), but not more complex interactions. It seems to be related to the GetValue member on SymbolicExpression.

Querying the loaded assemblies with reflection, it seems to think that System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is the loaded assembly version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething is broken!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions