SolvedIRkernel Dead kernel when running any R code, PNG and X11 related

Hi,

I'm not sure this is a bug but maybe just some clarification or a workaround required.

Seems related to Issue #386

When attempting to execute any R code (not even graphics related, just something like "a <- 1" will do it), the kernel dies.

Error output:

Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width,  :
  unable to start device PNG
Calls: <Anonymous> ... evaluate -> dev.new -> do.call -> <Anonymous> -> ok_device
In addition: Warning message:
In ok_device(filename, ...) : unable to open connection to X11 display ''
Execution halted

My R capabilities:

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

I'm running on a headless Centos 6.7 server. R was configured with X11 support but capabilities() says it's FALSE because a graphics device is not found.

However I have both PNG and Cairo support enabled, I'm wondering if "Cairo" is supposed to be preferenced over PNG?

I installed IRkernel from Github yesterday July 31st.

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS release 6.7 (Final)

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8
 [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8
 [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] IRkernel_0.6

loaded via a namespace (and not attached):
 [1] R6_2.1.2        magrittr_1.5    IRdisplay_0.4.3 pbdZMQ_0.2-3
 [5] tools_3.2.2     uuid_0.1-2      stringi_1.0-1   jsonlite_1.0

If this isn't a bug, my intention is to run an "xvfb" server to enable an X11 graphics device and see if that resolves the issue but I'd rather try to make it work without resorting to that.

Any help/info appreciated.

35 Answers

✔️Accepted Answer

You're right about still needing png() to work - I resolved my issue by setting ~/.Rprofile for "root" (Jupyterhub process user) as follows:

## Set default 'type' for png() calls - useful when X11 device is not available!
## NOTE: Needs 'cairo' capability
options(bitmapType='cairo')

Cheers!

More Issues: