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:

capabilities()
       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 
Sys.getenv("DISPLAY")
[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.

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=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
Bibhu

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: https://docs.rstudio.com/connect/admin/getting-started.html#install-r (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
libpng-1.2.49-2.el6_7.x86_64
[root@XXXX ~]# rpm -qa | grep -i  JPEG
openjpeg-libs-1.3-16.el6_8.x86_64
libjpeg-turbo-1.2.1-3.el6_5.x86_64
[root@XXXX ~]# rpm -qa | grep -i  Cairo
cairo-1.8.8-6.el6_6.x86_64
[root@XXXX ~]# rpm -qa | grep -i Pango
pango-1.28.1-11.el6.x86_64

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.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.