tweag / HaskellR

The full power of R in Haskell.

Home Page:https://tweag.github.io/HaskellR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inline-r with non-standard R installations

GregorySchwartz opened this issue · comments

This issue has been raised before, but I don't think there was a satisfactory conclusion:

For servers with multiple versions of R, how can I install and run a haskell package that relies on inline-r such that it uses the R that's in the path and uses those R packages and libraries? Errors such as this occur:

haskell-program-using-inline-r: R Runtime Error: Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/path/to/bin/R/NewR/R-3.4.3/library/stats/libs/stats.so': libRlapack.so: cannot open shared object file: No such file or directory

You have to set .libPaths e.g. .libPaths( c( .libPaths(), "~/userLibrary") ). I use nix and have

  shellHook = ''
    R_LIBS_USER=$(Rscript -e ".libPaths()" | cut -c 5- | Rscript -e ".libPaths()" | cut -c 5- | sed 's/[ \t]*$//' | sed 's/"//g' | sed -z 's/\n/:/g;s/:'''$/\n/' | sed 's/ //g')
    export R_LIBS_USER
    '';

which sets the environment variable that inline-r uses to the libPaths in the R I want to use (the one I just built in nix).

Given this is now nearly 3 years old, I am going to close the ticket but please don't hesitate to re-open it if you think it necessary.