tags:

views:

335

answers:

1

I'm running R 2.9 on a large EC2 Ubuntu instance, loaded with RAM, but without a terminal. When I load a library that has display dependencies, such as the sqldf package, I receive the following error:

library(sqldf)
...
Loading required package: tcltk
Loading Tcl/Tk interface ... Error in fun(...) : couldn't connect to display "localhost:11.0"
Error : .onLoad failed in 'loadNamespace' for 'tcltk'
Error: package 'tcltk' could not be loaded

This seems to be a general problem, and I'm wondering how others have solved it. Installing an X11 server is not a desirable solution.

+8  A: 

Use the virtual framebuffer X11 server -- we do the same to build packages requiring X11 for R builds in headless chroots. Taking e.g. pars of the Build-Depends from rggobi:

xvfb xauth xfonts-base

After installing these you can use the xvfb-run command. If you start R via e.g.

xvfb-run R --no-save

you should now be able to use routines and commands requiring X11 as e.g. some of the plotting devices, or the tcl/tk initialization which also insists on having X11.

The same trick is useful for web servers.

Dirk Eddelbuettel
Works brilliantly. Thank you.
dataspora