X11 is not available in R
Asked Answered
O

5

16

Problem

I'm following along some code and get an error related to X11. To recreate my error, I ran x11() and got the following:

> x11()
Error in x11() : X11 is not available

I have definitely plotted things in R that loaded the XQuartz program to display.

What I tried

  • I did ?x11() and saw that it is from the {grDevices} package. I loaded that library, tried again, but got the same error. I read that X11 is related to XQuartz.

  • I re-installed XQuartz 2.7.8. I have R 3.2.3 and am running OSX El Capitan version 10.11.4 (15E65). I restarted twice after re-installing.

  • install.packages("Cairo")

    > x11( width=3, height=3) Error in x11(width = 3, height = 3) : X11 is not available

    > Sys.getenv("DISPLAY") [1] "/private/tmp/com.apple.launchd.F1bsaVCA43/org.macosforge.xquartz:0"

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

Google researching

I Googled using my error message and searched through the first two pages of my results but didn't find any solutions that worked. Based on my perusal of solutions, I provided my system information above since it seems to be relevant somehow. Any ideas/solutions/new leads would be appreciated.

Oliphant answered 24/4, 2016 at 4:36 Comment(0)
P
4

The XQuartz package is the Mac X11 and your version is the current one. I'm wondering if you need to reboot after installation although I don't claim to know that. (And it might not hurt to repair permissions.) On my Mac (running 3.3.0 on El Cap) I need to set width and height (in inches, not pixels or points);

 x11( width=3, height=3)

What do you get with:

Sys.getenv("DISPLAY")

Might be something along the lines of:

"/private/tmp/com.apple.launchd.KImNTikz8K/org.macosforge.xquartz:0"

Also run:

capabilities()
Prime answered 24/4, 2016 at 5:2 Comment(1)
Thanks for your response. Not sure how to repair permissions. I followed your suggestions and edited my post to include the additional information to answer your questions.Oliphant
R
1

I had this same issue and installing R separately from Rstudio fixed it. You can download it from here and verify x11 is working using x11()

Ramey answered 7/9, 2016 at 5:53 Comment(1)
Yup, originally I tried to install R with Homebrew and had this issue. Then I uninstalled it and downloaded the R installer directly from the website and it finally worked.Prehension
B
1

You have to have a local X server, so get XQuartz because you are on MacOS.

If you were on Ubuntu you could install the virtual framebuffer X11 server like said here:

apt-get install xvfb xauth xfonts-base

Now that you have X virtual framebuffer installed, you can start a new instance like said here:

Xvfb :0 -ac -screen 0 1960x2000x24 &

Then if your R is compiled with with-x configuration option (enabled by default), you should have X11 capability, and you just have to declare this in R:

Sys.setenv("DISPLAY"=":0")
Brasilein answered 18/11, 2016 at 15:24 Comment(2)
OP is running MacOS "am running OSX El Capitan version 10.11.4", so your answer's unlikely to be useful to themQuarterhour
I was with the same problem on my R version 3.5.1 (2018-07-02) and after performing the very first instruction of this post (downloading and install XQuartz-2.7.11.dmg the problem was solved out. Thanks!Fivestar
I
1

You will need to download the R from cran (not Homebrew). After so doing the X11 will show up in capabilities() :

enter image description here

Idalia answered 14/11, 2021 at 11:59 Comment(0)
C
0

If you are compiling R in R 4.2.2 I realized that compiling normally would not build it with x11 capability. You have to specify it during ./configure by adding --with-x=yes.

Celestaceleste answered 2/2, 2023 at 16:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.