davidgohel / ReporteRs

Note that ReporteRs has been removed from CRAN the 16th of July 2018 and is not maintained anymore. please migrate to officer.
245 stars 44 forks source link

Strange behaviour when preloading ReporteRs into Rserve #179

Closed vzemlys closed 7 years ago

vzemlys commented 7 years ago

I have encountered a strange bug, when trying to use ReporteRs package via Rserve.

Here is how to reproduce it:

Start Rserve in the following way:

R CMD Rserve --RS-source load.R

where load.R contains only one line:

library(ReporteRs)

Now run the following R code:

library(RSclient)
con<-RS.connect()
RS.eval(con, pptx(title = "TTexport")) 

The Rserve hangs.

Now do the same but do not preload the ReporteRs package. I.e. start Rserve like (kill the previous Rserve process first)

R CMD Rserve

and run the code

library(RSclient)
con<-RS.connect()
RS.eval(con, ReporteRs::pptx(title = "TTexport")) 

In this case code executes and the result is the pptx object. So somehow preloading ReporteRs package results in the situation, where its code is not usable. It may be an issue with Rserve, but I noticed this behaviour only with ReporteRs package.

Here is my session_info():

R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 8 (jessie)

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
 [3] LC_TIME=en_US.UTF-8           LC_COLLATE=en_US.UTF-8       
 [5] LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8          
 [9] LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8     
[11] LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ReporteRs_0.8.6     ReporteRsjars_0.0.2

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.7       png_0.1-7         digest_0.6.10     mime_0.5         
 [5] R.methodsS3_1.7.1 R6_2.1.2          xtable_1.8-2      gdtools_0.1.1    
 [9] R.oo_1.21.0       R.utils_2.4.0     xml2_1.0.0        tools_3.3.2      
[13] shiny_0.14.1      httpuv_1.3.3      rJava_0.9-6       htmltools_0.3.5  
[17] rvg_0.1.1         knitr_1.13       
davidgohel commented 7 years ago

I am almost sure there is an issue with java. Is there a log for what happened?

See answer from Simon Urbanek: http://r.789695.n4.nabble.com/problem-using-rJava-with-parallel-mclapply-td4680245.html

In short, if RServe forks R processes, you won't be able to run R with ReporteRs.

If possible to migrate the code, you could switch to https://CRAN.R-project.org/package=officer

David

vzemlys commented 7 years ago

There is no log. Or I did not manage/want to find one. Explanation about forking suits me fine. The way I intend to use Rserve, forking is essential. Thanks for explanation and thanks for pointer to officer. I will definitely check it out.