Skip to content

xvfb? cron job updates R packages, fails on some requiring X11

4 messages · Paul Johnson, Duncan Murdoch, Dirk Eddelbuettel +1 more

#
In Centos 7 systems, I wrote a script that runs on the cron and I
notice some package updates and installs fail like this:


Error : .onLoad failed in loadNamespace() for 'iplots', details:
  call: .jnew("org/rosuda/iplots/Framework")
  error: java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an
operation which requires it.
Error: loading failed
Execution halted
ERROR: loading failed
* removing ?/usr/share/R/library/iplots?
* restoring previous ?/usr/share/R/library/iplots?


I can log in interactively and run  the same install successfully.

I understand I need something like xvfb to simulate an X11 session,
but I don't understand how to make it work.  Can one of you give me an
idiot's guide on what to do?

pj
#
On 19/01/2017 11:52 AM, Paul Johnson wrote:
I don't know if iplots offers this, but a package should be able to work 
in a non-X11 environment.  rgl does it by checking the RGL_USE_NULL 
environment variable.

Duncan Murdoch
#
Paul,

Just prefix the command as you would with, say, /usr/bin/time.  An example is here:

  https://github.com/RcppCore/rcpp-logs/blob/master/scripts/runRcppDepends.r#L140L-L142

from the script I use to test all Rcpp dependencies -- now over 900 -- unattended.

Some packages also need OpenGL which the default does not give you. But the
r-cran.mk script building several hundred r-cran-* package for the Debian and
Ubuntu distros -- as well as several _thousand_ r-cran-* packages via Michael
Rutter's repos for Ubuntu, and included in every installation, does this:


  ## xvfb-run with GL extension and default resolution
  xvfbSrvArgs 	= -screen 0 1024x768x24 -ac +extension GLX +render -noreset

  [...]

		if test -f /usr/bin/xvfb-run; then 			\
			$(makeFlagsCall) xvfb-run -a -n 20              \
                                                  -s "${xvfbSrvArgs}"   \
				R CMD INSTALL -l $(debRlib) --clean     \
					$(extraInstallFlags) .   	\
					$(builttimeStamp)   	        \
					;                               \


I guess you can piece the rest together.  Now, if you just used Ubuntu LTS
instead of insisting on CentOS you wouldn't even have to compile them
locally.  Might be worth a consideration or test deployment.

Dirk
1 day later
#
G'day Paul,

On Thu, 19 Jan 2017 10:52:16 -0600
Paul Johnson <pauljohn32 at gmail.com> wrote:

            
I do not know about Centos (i.e. how to install the necessary
software), but on my Ubuntu machines I have since years the following
in my crontab:

44 4 * * * cd /opt/src ; /usr/bin/xvfb-run ./R-devel-Doit
44 5 * * * cd /opt/src ; /usr/bin/xvfb-run ./R-aop-Doit

Those scripts update the R source code (development version and patched
version of latest official release, respectively), compile and install
from scratch, and update (if necessary) some contributed packages for
these R versions.  

I do not have iplots among the packages that I need for these R
versions, but I do have rgl and upgrades of the latter work (without
the need of setting any environment variables).

Hope this helps.

Cheers,
	
	Berwin