3

I have installed R 3.3.0 on a Centos server. I have installed multiple packages including shiny and further installed shiny server. I have loaded my app files and the app is running. I have some ggplot which is not rendering and I am getting a error message:

X11 is not available

I googled and did the following:

Upon running capabilities() in R console I am getting the following:

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

I installed :

yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"

yum install cairo-devel
yum install libXt-devel
install.packages("Cairo")
yum install xorg-x11-xauth
yum install xorg-x11-apps

All the above got installed but still I am getting the same error even after loading the library(Cairo).

When i run Sys.getenv("DISPLAY") in R i am getting a blank ""

One of the solutions here indicates that I should recompile R with ./configure --with-x=no. while another blog here indicates why I shouldn't do this. What I want to know is:

  1. Is there any solution I missed which could possibly help me?
  2. Can I remove R and reinstall from the beginning...(scares me, as I am sure what would transpire later and also have spent a lot of time setting up shiny-server)
  3. If I should recompile how do I go about this...will yum install r-base-dev./configure --with-x=no help?
Apricot
  • 2,925
  • 5
  • 42
  • 88

2 Answers2

3

Although this is an old question and it has some workarounds when you google it, I found a post about building R from source that makes this process easier.

First take a look at Building R from source

The commands you need to run in this post can be summarized as

yum install epel-release
yum install yum-utils  # to make yum-builddep command available

yum-builddep R # this command will install all the dependencies for building R from source
# Then under your R source folder run (I'm using R version 3.2.3, so you will want to change the version number in these commands):
./configure --prefix=/opt/R/3.2.3 --enable-R-shlib --with-blas --with-lapack # you can substitute your own target directory for /opt/R/3.2.3

make
make install

This will install R on your CentOS machine successfully. However, instead of having yum-builddep to install the dependence libraries for you, you can manually install these libraries, therefore you can skip those you already have.

If you re-run yum-builddep R, you will get all the dependencies installed, they are:

--> Already installed : zlib-devel-1.2.7-17.el7.x86_64
--> Already installed : xz-devel-5.2.2-1.el7.x86_64
--> Already installed : 1:valgrind-devel-3.11.0-24.el7.x86_64
--> Already installed : tre-devel-0.8.0-18.20140228gitc2f5d13.el7.x86_64
--> Already installed : 1:tk-devel-8.5.13-6.el7.x86_64
--> Already installed : texinfo-tex-5.1-4.el7.x86_64
--> Already installed : 2:texlive-collection-latexrecommended-svn25795.0-38.20130427_r30134.el7.noarch
--> Already installed : 1:tcl-devel-8.5.13-8.el7.x86_64
--> Already installed : readline-devel-6.2-9.el7.x86_64
--> Already installed : pcre-devel-8.32-15.el7_2.1.x86_64
--> Already installed : pango-devel-1.36.8-2.el7.x86_64
--> Already installed : openblas-devel-0.2.19-4.el7.x86_64
--> Already installed : ncurses-devel-5.9-13.20130511.el7.x86_64
--> Already installed : libtool-2.4.2-22.el7_3.x86_64
--> Already installed : libtiff-devel-4.0.3-27.el7_3.x86_64
--> Already installed : 2:libpng-devel-1.5.13-7.el7_2.x86_64
--> Already installed : libjpeg-turbo-devel-1.2.90-5.el7.x86_64
--> Already installed : libicu-devel-50.1.2-15.el7.x86_64
--> Already installed : libcurl-devel-7.29.0-35.el7.centos.x86_64
--> Already installed : libXt-devel-1.1.4-6.1.el7.x86_64
--> Already installed : libXmu-devel-1.1.2-2.el7.x86_64
--> Already installed : libX11-devel-1.6.3-3.el7.x86_64
--> Already installed : libSM-devel-1.2.2-2.el7.x86_64
--> Already installed : libICE-devel-1.0.9-2.el7.x86_64
--> Already installed : less-458-9.el7.x86_64
--> Already installed : 1:java-1.8.0-openjdk-headless-1.8.0.131-2.b11.el7_3.x86_64
--> Already installed : gcc-objc-4.8.5-11.el7.x86_64
--> Already installed : gcc-gfortran-4.8.5-11.el7.x86_64
--> Already installed : gcc-c++-4.8.5-11.el7.x86_64
--> Already installed : cairo-devel-1.14.2-1.el7.x86_64
--> Already installed : bzip2-devel-1.0.6-13.el7.x86_64
--> Already installed : automake-1.13.4-3.el7.noarch
--> Already installed : autoconf-2.69-11.el7.noarch

As a result you can choose to just install some of these libraries according to what your current libraries are especially if you already installed 'Development Tools' or some other packages.

In my case, I have Oracle JDK installed so I don't need open-jdk installed by yum-builddep, so I removed the open-jdk and the compilation passed without any errors when I set JAVA_HOME correctly.

lkq
  • 2,326
  • 1
  • 12
  • 22
0

Even after installed X11 on the system I still had issues with getting it to work. Make sure that Cairo is also installed. Note this is working on the assumption that if you open R in the terminal and type x11() you no longer get the "X11 is not available error".

  • ensure that Cairo is installed: yum install cairo

can test with the below command (thanks to https://github.com/IRkernel/IRkernel/issues/388)

library(datasets) png("test.png", width=1200, height=1200, units="px", type="cairo") boxplot(mpg~cyl,data=mtcars, main="Car Milage Data", xlab="Number of Cylinders", ylab="Miles Per Gallon") dev.off()

  • install Cairo within R itself: install.packages("Cairo")