Shiny app runs fine on RStudio, but it doesn’t run on public server, throwing this error instead:
Error in (function (file = if (onefile) "Rplots.pdf" else "Rplot%03d.pdf", :
cannot open file 'Rplots.pdf'
Calls: runApp ... ..stacktraceon.. -> <Anonymous> -> par -> <Anonymous>
Execution halted
This error appears because there is code in your app that tries to generate a plot in a non-interactive R session (usually server.r or global.r). To quote Yihui Xie:
From my experience, this is often an indication that your have some code that generates plots in a non-interactive R session, and the default graphics device for a non-interactive R session is pdf(). R tried to capture the plot and writes Rplots.pdf, but failed probably due to the fact that you don't have write permission to the working directory. Your server.R contains a call to palette(), which I believe will trigger Rplots.pdf. You can try to move it inside renderPlot({}) and see if the problem goes away.
In my case, it was a leftover call to scales::show_col()
in my global.r
file, from testing some color pallettes.