Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R unable to start device PNG - capabilities() has TRUE for PNG?

Tags:

r

I am working with a R script within a wider pipeline that seems to not work with some versions of Rscript but with others. The call fails due to being unable to connect to X11, which is understandable because this is on a server. But my local installation of Rscript is able to handle this fine?

My local installation is version 3.0.1, while the one that other users that are reporting this problem are on 3.0.2.

Here is a simple test case - first the .R file:

#!/usr/bin/env Rscript

capabilities()

png("abc")

dev.off()

Run with my local env:

-bash-4.1$ ./test.R
    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets 
    TRUE     TRUE     TRUE     TRUE    FALSE    FALSE     TRUE     TRUE 
  libxml     fifo   cledit    iconv      NLS  profmem    cairo 
    TRUE     TRUE    FALSE     TRUE     TRUE    FALSE     TRUE 
null device 
          1 

Run on the installation of Rscript others are trying to use:

    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets 
    TRUE     TRUE    FALSE     TRUE    FALSE    FALSE     TRUE     TRUE 
  libxml     fifo   cledit    iconv      NLS  profmem    cairo 
    TRUE     TRUE    FALSE     TRUE     TRUE    FALSE     TRUE 
Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width,  : 
  unable to start device PNG
Calls: png
In addition: Warning message:
In png("abc") : unable to open connection to X11 display ''
Execution halted
like image 318
Ian Fiddes Avatar asked Jul 28 '14 16:07

Ian Fiddes


1 Answers

In case anyone ever finds this on google, the solution is

png("abc", type="cairo")
like image 106
Ian Fiddes Avatar answered Oct 08 '22 19:10

Ian Fiddes