[Rd] [R] Sweave stops when opening X11 device fails

peter dalgaard PDalgd at gmail.com
Tue May 3 13:19:58 CEST 2011

On May 3, 2011, at 12:35 , Andreas Borg wrote:

> Hi all,
> I am posting this again because I got no reply on r-help. Maybe the devel-list is the right place for this kind of question.

Actually, not an R problem at all, but try one of these...

1) get rid of the DISPLAY environment variable before starting R 

2) replace the su command with ssh -Y localhost to get the X server tunneled properly.

3) xhost +localhost  (may be a security liability)


> I've run into the following problem with Sweave: I frequently run Sweave
> from a xterm console within an X session owned by a different user, i.e.
> my colleague is logged in on this computer and I do "su" with my
> username and start R and Sweave afterwards. Now, when Sweave comes to a
> figure chunk, it sees that there is an X server running and tries to
> show whatever I plot in that chunk on the screen, additionally to
> writing a pdf file. The problem is that I am not logged into the X
> session myself, and the script fails with a message saying someting like
> "could not open device X11" (I have German messages, so I do not know
> what the exact phrase would be in English). When I log in with putty,
> where there is no X11 at all, everything works fine. Is there a way to
> prevent Sweave from failing in the former case? Would this even account
> as a bug? I think it would be nice if the script just kept on running
> without plotting on the screen if opening X11 fails, just like it does
> when no X11 is available at all.
> Best regards,
> Andreas
> p.s.: I would be willing to dig in the code and look for a fix myself, but it would be great if anyone could give a hint where to look. I suspect "RweaveDriverRuncode" is the right place, but in what namespace is it?
> -- 
> Andreas Borg
> Medizinische Informatik
> der Johannes Gutenberg-Universität
> Institut für Medizinische Biometrie, Epidemiologie und Informatik
> Obere Zahlbacher Straße 69, 55131 Mainz
> www.imbei.uni-mainz.de
> Telefon +49 (0) 6131 175062
> E-Mail: borg at imbei.uni-mainz.de
> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der
> richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
> Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe
> dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com

More information about the R-devel mailing list