Not able to trigger the graphics using RSTUDIO

Hi ,

I have added the parameter as rsession-which-r=/opt/cloudera/extras/R-latest/bin/R in /etc/rstudio/rserver.conf and did the rstudio stop and start, but still i am getting the below error while trying to trigger the graphics. You can find the information related to RStudio as mentioned below. Please suggest what needs to be done.

Error in RStudioGD() : 
  Shadow graphics device error: r error 4 (R code execution error)
In addition: Warning message:
In grDevices:::png("/tmp/Rtmpugt1Dx/f3785ca553194f7db553869d743cb903.png",  :
  unable to open connection to X11 display ''

Below are the information related to RStudio:

       jpeg         png        tiff       tcltk         X11        aqua    http/ftp     sockets 
      FALSE       FALSE       FALSE        TRUE       FALSE       FALSE        TRUE        TRUE 
     libxml        fifo      cledit       iconv         NLS     profmem       cairo         ICU 
       TRUE        TRUE        TRUE        TRUE        TRUE        TRUE       FALSE        TRUE 
long.double     libcurl 
       TRUE        TRUE 
[1] ":0"

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.10 (Santiago)# This is a "SLES Expanded Support platform release 6.10"# The above "Red Hat Enterprise Linux Server" string is only used to # keep software compatibility.

[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              

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

other attached packages:
[1] ggplot2_2.1.0

loaded via a namespace (and not attached):
[1] colorspace_1.2-6 scales_0.4.0     plyr_1.8.4       tools_3.3.1      gtable_0.2.0    
[6] Rcpp_0.12.5      grid_3.3.1       munsell_0.4.3

Thanks and Regards

Hi @bibhusisa,

As you can see from the call to capabilities(), a number of the graphical capabilities aren't installed for your R instance, including png. It looks like you're using a Cloudera installation of R, which must have been compiled without those capabilities enabled. We generally recommend installing R from source to make sure all of the capabilities are properly compiled.

The easiest way to fix this problem is to reinstall R from source.

Instructions are doing so are here: (The process is the same for RStudio Server and RStudio Connect, and these instructions have been updated more recently).

After the configure step in the instructions, you should be able to see which capabilities are enabled so you can adjust system dependencies as might be needed.

Also, see this question for more help: Warning: Error in .External2: unable to start device PNG

Let us know how it goes!

1 Like

Hi @alexkgold ,

Thank you so much for your reply. as per my understanding PNG or JPEG will help R and RStudio to produce plots. Cairo is a graphics library for creating high quality bitmap(PNG, JPEG, TIFF) and vector(PDF, SVG, PostScript). Pango is a library for laying out and it is adapting in text, with an emphasis on internationalization.

All the above packages are installed in the server other than vector, please find the rpm -qa | grep -I {pkg name}. even I have provided the path where all the packages are available that is rsession-which-r=/opt/cloudera/extras/R-latest/bin/R in /etc/rstudio/rserver.conf and restarted the rstudio but same error. could you please suggest whether is it mandatory to reinstall the RSTUDIO or any thing I can do without reinstall because its prod environment, we can not re install without taking many approval please suggest.

[root@XXXX ~]# rpm -qa | grep -i PNG
[root@XXXX ~]# rpm -qa | grep -i  JPEG
[root@XXXX ~]# rpm -qa | grep -i  Cairo
[root@XXXX ~]# rpm -qa | grep -i Pango

Hi @bibhusisa,

Unfortunately the capabilities are determined by what libraries R was compiled against, not what's available on the system now now. Just to be clear, you don't have to remove the existing version of R, but you do have to install a new one that has been compiled against the display libraries you need.

In my case, the problem was to use brew on my Ubuntu 16.04. I had same error msg "Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error) ..."
after using Linuxbrew to install R and then using apt-get remove ... and apt-get purge ... to uninstall R and Rstudio before using apt-get to reinstall. apt-get didn't cleanly uninstall R.

I was able to get rid of this error only when I used brew to uninstall R and cleaned up all R related folders before using apt-get to do a fresh new installation of R-base and RStudio.