COVAIL / photon

RStudio Add-in to build Shiny apps utilizing the Electron framework
125 stars 25 forks source link

Pandoc Error for Rmarkdown::render() #7

Closed Felixmil closed 1 year ago

Felixmil commented 4 years ago

Problem Description:

I'm trying to turn a simple app into an exe using your electron based framework.

After launching RStudio on the R-Portable-Win folder, the app is working fine. Except for the Rmarkdown reports generation function, the error is :

pandoc.exe: C:\Users\[user]\: openBinaryFile: does not exist (No such file or directory)

This error appears after the whole doc have been processed (.md file have been generated).

It seems that the R session cannot locate the pandoc.exe while when I type (in the same session):

rmarkdown::pandoc_version()
[1] ‘2.7.2’

and

Sys.getenv("RSTUDIO_PANDOC")
"C:\[installation folder]\\RStudio-1.2.5001\\bin\\pandoc"

so Pandoc is actually installed on my computer.

What I tried

💡 Setup a RSTUDIO_PANDOC variable in Rprofile

Sys.setenv(RSTUDIO_PANDOC = "C:/[path to app folder]/pandoc")
Sys.getenv("RSTUDIO_PANDOC")

:x: Result: Same error

Questions

(reproducible exemple is on the way)

petegordon commented 4 years ago

I'd suggest maybe electron is not meant for rmakrdown/knitr/pandoc because it is all about shiny apps being run as electron executables. You cannot simply run RStudio on the R-Portable-Win.

If you must do documentation then you need to add the library/package(s) (for example https://cran.r-project.org/web/packages/knitr/index.html) electron-quickstart by running R-Portable-Win/bin/R and install_packages so that it is installed in the local directory library (where all local directory packages are installed and available from)... https://github.com/ColumbusCollaboratory/electron-quick-start/tree/master/R-Portable-Win/library

The easiest way this is done is in the Add-On you add the packages needed. Have you done that? Once it runs the package install it should be seen in the R-Portable-Win/library if it was installed correctly. If not installed and in the directory; then try to run the R-Portable-Win/bin/R directly and see if you can run it; this will show you successful or unsuccessful install of the package in the local R-Portable-Win/library directory. This is the most important thing for packages to be used in electron and R-Portable-Win. Keep in mind R-Portable-Win is a R console runtime--it is not RStudio project.

Try that stuff. Thanks!

Felixmil commented 4 years ago

Thanks for your help.

I indeed installed all the libraries my app needs, directly from RStudio (Using the option that let you use the R installation folder you want in Tools>General Settings, not as a RStudio Project). All are correctly installed in the R-Portable-Win folder.

The thing with rmarkdown is that it uses a pandoc.exe that comes with a RStudio installation, not from a library. Anyway, I managed to generate a HTML file from the app (as npm start) earlier tonight. I feel I'm close and will keep documenting my progress here.

A note: I think report generation through Shiny is a great way to achieve reproducible, interactive and accessible data analysis. Having that in Proton would open the power of data to a whole new chunk of users ! In my case : machines maintainers that are sometimes in remote areas without access to our servers that could use a classification model based diagnostic tool to help them target the issue. A simple USB key would be their new toolbox. :wrench:

ocelhay commented 4 years ago

Hi @Felixmil I have the same issue. Did you manage to have pandoc added to the electron shiny app?

petegordon commented 4 years ago

Maybe a way to address this is to create a new “bin” directory under the the electron application root directory; as a sibling to the R-Portable directory and then install pandoc exe into that directory and set the absolute path to it in your Shiny application. That should work if pandoc can be executed directly from a directory. It won’t be available as a global command line executable, but that’s because everything in election we are trying to package up self-contained anyway. Give it a try and let us know.