New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround when no graphics device is available (Error: cannot open file 'Rplots.pdf') #494

Closed
yonicd opened this Issue Mar 10, 2016 · 20 comments

Comments

Projects
None yet
7 participants
@yonicd

yonicd commented Mar 10, 2016

i wrote a shiny app with plotly and while testing it in the localhost provided with rstudio on windows it looked great. I then deployed it to shinyapps.io and got the same result. But when I deploy it on an ubuntu aws instance it goes crazy.... the date x axis scale is nonresponsive (only shows %x %T), the overlay for trends are all over the place, ... and more. The "bugs" are much more pronounced in the new version of the plotly package. Currently I reverted back to the cran version.

what could be the specifications of the aws instance that is causing the plotly library to go crazy?

@cpsievert

This comment has been minimized.

Show comment
Hide comment
@cpsievert

cpsievert Mar 11, 2016

Contributor

Hmm, it might have to do eval(parse()), but could also have to do with the R/shiny server version you're running on your instance

Contributor

cpsievert commented Mar 11, 2016

Hmm, it might have to do eval(parse()), but could also have to do with the R/shiny server version you're running on your instance

@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 11, 2016

the eval(parse(...)) is working on the other platforms so it shouldnt be a problem. i tried to remove the deb package to reinstall the server from scratch but couldnt for some reason:

this is after i reinstalled the server from the rstudio site

ubuntu@ip-172-31-24-42:~$ ls
shiny-server-1.4.1.759-amd64.deb (archive)  shiny-server-1.4.2.786-amd64.deb (archive)  shiny-server-1.4.2.786-amd64.deb.1

would these redundant versions be the cause the problem?

anyway this is my current version installed

ubuntu@ip-172-31-24-42:/srv$ apt-cache showpkg shiny-server
Package: shiny-server
Versions:
1.4.2.786 (/var/lib/dpkg/status)
 Description Language:
                 File: /var/lib/dpkg/status
                  MD5: 5692122708280493808d4d49f42a0475


Reverse Depends:
Dependencies:
1.4.2.786 - libc6 (2 2.7) r-base (2 2.15.1)
Provides:
1.4.2.786 -
Reverse Provides:

yonicd commented Mar 11, 2016

the eval(parse(...)) is working on the other platforms so it shouldnt be a problem. i tried to remove the deb package to reinstall the server from scratch but couldnt for some reason:

this is after i reinstalled the server from the rstudio site

ubuntu@ip-172-31-24-42:~$ ls
shiny-server-1.4.1.759-amd64.deb (archive)  shiny-server-1.4.2.786-amd64.deb (archive)  shiny-server-1.4.2.786-amd64.deb.1

would these redundant versions be the cause the problem?

anyway this is my current version installed

ubuntu@ip-172-31-24-42:/srv$ apt-cache showpkg shiny-server
Package: shiny-server
Versions:
1.4.2.786 (/var/lib/dpkg/status)
 Description Language:
                 File: /var/lib/dpkg/status
                  MD5: 5692122708280493808d4d49f42a0475


Reverse Depends:
Dependencies:
1.4.2.786 - libc6 (2 2.7) r-base (2 2.15.1)
Provides:
1.4.2.786 -
Reverse Provides:
@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 12, 2016

I figured out its one problem that is causing a lot of the graphs to look bad. the dates get mixed up so the x date axis isnt monotonous. what could cause that?

when i install the current plotly package i get this error: cannot open file 'Rplots.pdf'
i thought it was from the ggsave function in the download handler but i removed that button and it still gives same error. (again this is only in the aws server)

yonicd commented Mar 12, 2016

I figured out its one problem that is causing a lot of the graphs to look bad. the dates get mixed up so the x date axis isnt monotonous. what could cause that?

when i install the current plotly package i get this error: cannot open file 'Rplots.pdf'
i thought it was from the ggsave function in the download handler but i removed that button and it still gives same error. (again this is only in the aws server)

@cpsievert

This comment has been minimized.

Show comment
Hide comment
@cpsievert

cpsievert Mar 12, 2016

Contributor

Hmm, a minimal example of the date problem would be great.

Are you using devtools::install_github("ropensci/plotly") to install?

Contributor

cpsievert commented Mar 12, 2016

Hmm, a minimal example of the date problem would be great.

Are you using devtools::install_github("ropensci/plotly") to install?

@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 13, 2016

simple example, r files

the plotly package version is in the ggtitle.

yonicd commented Mar 13, 2016

simple example, r files

the plotly package version is in the ggtitle.

@cpsievert

This comment has been minimized.

Show comment
Hide comment
@cpsievert

cpsievert Mar 13, 2016

Contributor

Thanks, I'll be creating a separate issue for that example

Contributor

cpsievert commented Mar 13, 2016

Thanks, I'll be creating a separate issue for that example

@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 13, 2016

i added the economics df to be sure its not "my data" that is causing the problem (its not). One weird by product of updating the plotly build is that its giving out an error of Rplots.pdf that it can't produce. Currently i reverted it back again to the cran build so the plot will be generated

yonicd commented Mar 13, 2016

i added the economics df to be sure its not "my data" that is causing the problem (its not). One weird by product of updating the plotly build is that its giving out an error of Rplots.pdf that it can't produce. Currently i reverted it back again to the cran build so the plot will be generated

@cpsievert

This comment has been minimized.

Show comment
Hide comment
@cpsievert

cpsievert Mar 13, 2016

Contributor

Can you provide code to replicate the cannot open file 'Rplots.pdf' error?

Contributor

cpsievert commented Mar 13, 2016

Can you provide code to replicate the cannot open file 'Rplots.pdf' error?

@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 13, 2016

its a byproduct of plotly installation. it is kind of hard to do since it comes up when i run shiny from the linux server. on my windows r/rstudio it is an error only when using ggsave because it cant write to the pdf file.

this is an example of other people getting the error. another example

yonicd commented Mar 13, 2016

its a byproduct of plotly installation. it is kind of hard to do since it comes up when i run shiny from the linux server. on my windows r/rstudio it is an error only when using ggsave because it cant write to the pdf file.

this is an example of other people getting the error. another example

@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 13, 2016

this is from the shiny-server log

root@ip-172-31-24-42:/var/log/shiny-server# cat plotlytest-shiny-20160313-072240-49377.log

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

    last_plot

The following object is masked from ‘package:graphics’:

    layout


Listening on http://127.0.0.1:49377
ERROR: [on_request_read] connection reset by peer
Warning: Error in <Anonymous>: cannot open file 'Rplots.pdf'
Stack trace (innermost first):
    76: <Anonymous>
    75: grid.Call
    74: convertUnit
    73: grid::convertHeight
    72: unitConvert
    71: gg2list
    70: plotly_build
    69: as.widget
    68: func
    67: output$TestPlot
     1: runApp

yonicd commented Mar 13, 2016

this is from the shiny-server log

root@ip-172-31-24-42:/var/log/shiny-server# cat plotlytest-shiny-20160313-072240-49377.log

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

    last_plot

The following object is masked from ‘package:graphics’:

    layout


Listening on http://127.0.0.1:49377
ERROR: [on_request_read] connection reset by peer
Warning: Error in <Anonymous>: cannot open file 'Rplots.pdf'
Stack trace (innermost first):
    76: <Anonymous>
    75: grid.Call
    74: convertUnit
    73: grid::convertHeight
    72: unitConvert
    71: gg2list
    70: plotly_build
    69: as.widget
    68: func
    67: output$TestPlot
     1: runApp
@cpsievert

This comment has been minimized.

Show comment
Hide comment
@cpsievert

cpsievert Mar 13, 2016

Contributor

Ah, I have a feeling grid.Call is throwing that error because it can't open a device window. As this suggests, instead of just evaluating p, try evaluating this:

png("NUL")
p
dev.off()

Let me know how it goes!

Contributor

cpsievert commented Mar 13, 2016

Ah, I have a feeling grid.Call is throwing that error because it can't open a device window. As this suggests, instead of just evaluating p, try evaluating this:

png("NUL")
p
dev.off()

Let me know how it goes!

@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 13, 2016

works!

the correct call is

pdf(NULL)
MakePlot()

now the parser on the shinyAce is causing problems. but that is something workable.

thanks!

yonicd commented Mar 13, 2016

works!

the correct call is

pdf(NULL)
MakePlot()

now the parser on the shinyAce is causing problems. but that is something workable.

thanks!

@cpsievert cpsievert changed the title from plotly not loading correctly on linux server to Workaround when no graphics device is available (Error: cannot open file 'Rplots.pdf') Mar 15, 2016

@cpsievert cpsievert closed this Mar 15, 2016

@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 30, 2016

A follow up remark/question. After i published the app and got many simultaneous users I get "too many open devices" error on plots. could this be a shiny thing or a result of the workaround we did for plotly?

yonicd commented Mar 30, 2016

A follow up remark/question. After i published the app and got many simultaneous users I get "too many open devices" error on plots. could this be a shiny thing or a result of the workaround we did for plotly?

@cpsievert

This comment has been minimized.

Show comment
Hide comment
@cpsievert

cpsievert Mar 30, 2016

Contributor

Hmm, it's probably a limitation of your machine (it can only open so many graphics devices). Chalking this up as motivation for pursuing an approach that doesn't make calls to the graphics device as I elude to in #489

Contributor

cpsievert commented Mar 30, 2016

Hmm, it's probably a limitation of your machine (it can only open so many graphics devices). Chalking this up as motivation for pursuing an approach that doesn't make calls to the graphics device as I elude to in #489

@yonicd

This comment has been minimized.

Show comment
Hide comment
@yonicd

yonicd Mar 30, 2016

Is there any way to force close devices when an instance is running?

yonicd commented Mar 30, 2016

Is there any way to force close devices when an instance is running?

@dbuijs

This comment has been minimized.

Show comment
Hide comment
@dbuijs

dbuijs Apr 21, 2016

I had this exact issue. I found it was completely addressed by changing the owner and group of my shiny app folder to shiny:shiny (since all shiny apps are run as the shiny user).

dbuijs commented Apr 21, 2016

I had this exact issue. I found it was completely addressed by changing the owner and group of my shiny app folder to shiny:shiny (since all shiny apps are run as the shiny user).

@hutchike

This comment has been minimized.

Show comment
Hide comment
@hutchike

hutchike May 26, 2016

@dbuijs thanks! chown -R shiny:shiny /srv/shiny-server worked for me too 👍

hutchike commented May 26, 2016

@dbuijs thanks! chown -R shiny:shiny /srv/shiny-server worked for me too 👍

Deleetdk added a commit to Deleetdk/brexit_model that referenced this issue Jun 7, 2016

Remove debug code + add GH link
Solved the bug by changing permissions instead. See
ropensci/plotly#494
@vielleicht

This comment has been minimized.

Show comment
Hide comment
@vielleicht

vielleicht Sep 13, 2016

I used the following code and it works with secondly update for hours

if (names(dev.cur()) != "null device") dev.off()
pdf(NULL)

I first didn't use the dev.off() and then it crashed after some time.

vielleicht commented Sep 13, 2016

I used the following code and it works with secondly update for hours

if (names(dev.cur()) != "null device") dev.off()
pdf(NULL)

I first didn't use the dev.off() and then it crashed after some time.

MaurerThomas added a commit to JKetelaar/Sleeping-Pattern that referenced this issue Jan 15, 2017

dmattek added a commit to dmattek/shiny-timecourse-inspector that referenced this issue Mar 6, 2017

Bug fix:
Error shows up in app log when plotting.

"Warning: Error in <Anonymous>: cannot open file 'Rplots.pdf'"

Fix based on: ropensci/plotly#494

Added in plotting f-n:
if (names(dev.cur()) != "null device") dev.off()
pdf(NULL)
@gcmicah

This comment has been minimized.

Show comment
Hide comment
@gcmicah

gcmicah Nov 16, 2017

can someone please tell me which file and where to add pdf(NULL) ? I have tried put it in server.R and the R contains my plot, but it didn't work.
thanks.

gcmicah commented Nov 16, 2017

can someone please tell me which file and where to add pdf(NULL) ? I have tried put it in server.R and the R contains my plot, but it didn't work.
thanks.

@z4chry

This comment has been minimized.

Show comment
Hide comment
@z4chry

z4chry Mar 23, 2018

@gcmicah it goes in server.R within the function that is generating the plot.

What worked for me was pdf(file = NULL).

Here's what it looks like for me:
tm <- treemap( df, index = c("Ch", "Q"), vSize = "F", vColor = "Ch", pdf(file = NULL) )

z4chry commented Mar 23, 2018

@gcmicah it goes in server.R within the function that is generating the plot.

What worked for me was pdf(file = NULL).

Here's what it looks like for me:
tm <- treemap( df, index = c("Ch", "Q"), vSize = "F", vColor = "Ch", pdf(file = NULL) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment