[Rd] Bug using X11 on mac osx (for jpeg or png creation) (PR#10800)

bonneaud at enib.fr bonneaud at enib.fr
Tue Feb 19 14:25:04 CET 2008

Full_Name: Stephane Bonneaud
Version: 2.6.2 
OS: OSX - Leopard 10.5.2
Submission from: (NULL) (


I have a R code file containing the following code:

# This code is in r2jpg.r
# myData is filled here with some data from a file 
plot(myData,xlab="anything", ylab="whatever",type="b",col="red", lwd=4)

I executed this code within both the R GUI and the command line. When launched
through the R GUI (Mac OS X Cocoa GUI - GUI 1.22-devel (4844) (4844)),
everything works just fine. The JPEG file is generated just I want. Great!
The problem is when I try to execute the code through the command line in
Terminal (OSX).
I execute my code using the following command :
cat r2jpg.r | R --silent --no-restore --no-save

And I get the following error:

> jpeg(filename="test.jpg",width=960,height=720,pointsize=16,quality=100)
can't find X11 font
Error in X11(paste("jpeg::", quality, ":", filename, sep = ""), width,  : 
  impossible to start the peripheral JPEG
Calls: jpeg

(Sorry, I translated the error messages from french so it might be a little
different in english. If needed I can print it in english though)

I saw that several persons had this problem, but did not find any proper
solution. Therefore, I tried to launch my command from xterm (still in OSX) and
not in Terminal, and it worked. There is definitely an issue with R getting the
proper environment variables for X11 or something like that when launched from
the command line in Terminal.
When you launch the GUI, OSX detects it will need X11 (or something like this
:b), therefore all proper env variables are charged. From xterm, obviously the
proper env variables are set.

How could R tell OSX to link with X11 when launched from command line in

PS: sorry, it might be a leopard bug, but I thought somebody could be interested
in the R community. And maybe R developers might actually be able to do

More information about the R-devel mailing list