Problems with plot after new install: Error in RStudioGD() :


I recently upgraded to Linux mmint 19 and reinstalled R and Rstudio on my
computer. I keep getting this error when I try to plot something. The plot
function works fine in R.

Error in RStudioGD() :
  Shadow graphics device error: r error 4 (R code execution error)
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
50: In
... :
  failed to load cairo DLL

I check various forums, and I updated Cairo and Pango libraries and
reinstalled R and Rstudio but still get the error. Could someone help me
out with this problem? Thanks

Here are the outputs to SessionInfo

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/atlas/
LAPACK: /usr/local/lib/R/lib/

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

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

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1

> options('device')
[1] "RStudioGD"

Thanks in advance for any advice,

You seem to have hit all the points in the advice here:

You said that you already rebuilt R against that newly-installed Cairo library?


Yes, though to make sure, I'll do it again. Is there some path that I need to upgrade? Maybe Rstudio is looking for a file in the wrong place.

How did you build and configure R? Note that you'll need to configure R with --with-cairo for plots to work.

I compiled it from source. I used the following configure command:

./configure --prefix=/opt/R/3.5.1 --enable-R-shlib --with-blas --with-lapack --with-libpng --with-jpeglib

I'll reinstall with --with-cairo, after I issue a make uninstall command for R and uninstall Rstudio. Thanks for the tip.


I reconfigured with
./configure --prefix=/opt/R/3.5.1 --enable-R-shlib --with-blas --with-lapack --with-cairo --with-libpng --with-jpeglib

I still got the same error.

This old support article might be relevant:

It would be useful to know what the extra warnings emitted by R here are, as well. (You can enter warnings() after attempting to generate the plot to see what warnings are being emitted)

1 Like


I was able to fix the issue thanks to your post. So, I did warnings() and I got this message:

Warning messages:
1: In grDevices:::png("/tmp/Rtmp700CWS/59baa711a2fb4bb48fc3ff4cdb6c579d.png", ... :
unable to load shared object '/usr/local/lib/R/library/grDevices/libs//':
/usr/local/lib/R/library/grDevices/libs// cannot open shared object file: No such file or directory
2: In grDevices:::png("/tmp/Rtmp700CWS/59baa711a2fb4bb48fc3ff4cdb6c579d.png", ... :
failed to load cairo DLL

I looked in /usr/local/lib/R/library/grDevices/libs and did not find but there was one in the /opt directory so I created a soft link

sudo ln -s /opt/R/3.5.1/lib/R/library/grDevices/libs/

and plots are working fine. I missed this earlier, because it gave 50 warnings and since the last 15 or so looked similar, I didnt scroll up to see the first one, assuming that they were all the same.

Thanks a lot kevinushey and EconomiCurtis for your help.



looks to me like an extra / in the path

Warning messages:
1: In grDevices:::png("/tmp/RtmpPo9zq7/1273aa6e4d4543029217f6a08f4fd4fe.png", ... :
unable to load shared object '/usr/lib64/R/library/grDevices/libs//':

1 Like