Skip to content

png-generation from script (non-X11 env) now broken?

7 messages · Massimo Di Stefano, Ista Zahn, Jeff Newmiller +2 more

#
Since ... hmmm.. May 2012, I've had a cron-initiated script running
monthly to extract some data and generate some numeric tables and
plots (in PNG format).

In its "normal" mode, the script automagically sends its results
to a small handful of managers on the first of each month.  Out of
self-defense, I set up a "preview" run several days before the real
one; the preview doesn't go quite as high in the management chain.

This morning, I found a message in my mailbox from such a preview run:

| Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width,  :
|   unable to start device PNG
| Calls: gen_build_histogram -> png
| In addition: Warning message:
| In png(filename = fn, height = height, width = width, units = "in",  :
|   unable to open connection to X11 display ''
| Execution halted

[This was running R-3.0.2_1 in FreeBSD/amd64 9.2-STABLE 
r262323M/262357:902506, built Sun Feb 23 05:14:37 PST 2014.]

I admit that I haven't been following changes in R very closely --
the script had been running reliably for over a year, and it's not
one of the fires I've been fighting recently.

But the implication -- that png() was suddenly[1] changed so that it
requires the ability to connect to an X11 display -- seemed peculiar
enough that I would have thought a quick search would lead me to soe
discussion of a change of this magnitude, rationale, and what folks
might do to mitigate the effects.

Based on one message I found (from 02 Mar 2008!), I did take a look at
"help png" output, and saw the reference there to bitmap().  I tried ...
hacking ... my functions to use "bitmap(fn, ...)" instead of
"png(filename = fn, ...)", but that looks as if it's leading me astray:

| Error in strwidth(legend, units = "user", cex = cex, font = text.font) : 
|   family 'mono' not included in postscript() device
| Calls: gen_build_histogram -> legend -> strwidth
| Execution halted


So... what's someone who wants to use R to generate PNG-format files
from an environment that is bereft of X11 to do?


1: "Suddenly" because it *had* been working up to 01 Feb 2014, at least.

[I'll be happy to sumamrize responses that aren't sent to the list.]

Peace,
david
#
Hi,

You can try to use cairo instead of png.
IT doesn?t require X.
try putting this line in a Rprofile file :


	options(bitmapType="cairo") 


Massimo.
On Feb 25, 2014, at 1:36 PM, David Wolfskill <r at catwhisker.org> wrote:

            
#
Hi David,

Did you see https://stat.ethz.ch/pipermail/r-help/2010-March/231778.html
? What does capabilities() tell you?

Best,
Ista
On Tue, Feb 25, 2014 at 1:36 PM, David Wolfskill <r at catwhisker.org> wrote:
#
This is really not new... Google is your friend... http://bit.ly/1fCUnQH... or read FAQ 7.19. The fact that this "changed" for you seems more like something changed on your end... did your admin remove X11 from your system?
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
On February 25, 2014 10:36:29 AM PST, David Wolfskill <r at catwhisker.org> wrote:
#
On Tue, Feb 25, 2014 at 11:10:12AM -0800, Jeff Newmiller wrote:
I am my sysadmin.  (I actually was one for about 3 decades prior to my
current position.  I am not now, nor have I ever been, a statistician.)

I had never had an issue (since May 2012) creating a PNG file from a
script running out of crontab -- thus my surprise when it failed.

As an experiment, I tried running the script in an xterm that had
DISPLAY defined properly; the PNG files were created (without
displaying them on the X11 display device), but I did get some odd
messages, and a couple of the plots came out effectively blank
(which I don't find especially useful):

Warning message:
In grid.Call.graphics(L_polygon, x$x, x$y, index) :
  semi-transparency is not supported on this device: reported only once per page

Warning message:
In plot.xy(xy, type, ...) :
  semi-transparency is not supported on this device: reported only once per page

(These were from plots where I specified an "alpha" value.  The
first was from a invocation of the form:

p <- qplot(..., geom = c("blank"), ...) + geom_violin(..., fill=I("steelblue")) + geom_boxplot(..., fill="gold", alpha=0.75)

and the second, of the form:

plot(xvals, yvals, pch = ".", col = col_list, ...)

  where "col_list" is a list of colors, each of which includes a
  specification of "alpha = 0.2".)

Peace,
david
#
On Tue, Feb 25, 2014 at 10:36:29AM -0800, David Wolfskill wrote:
The above is no longer a problem.

After a variety of approaches, I decided to rebuild the graphics/png,
graphics/cairo, and all of the R-* ports on the machine.  A summary:

===>>> The following actions were performed:
        Re-installation of png-1.5.18
        Re-installation of cairo-1.10.2_7,2
        Re-installation of R-3.0.2_1
        Re-installation of R-cran-DBI-0.2.7_3
        Re-installation of R-cran-RColorBrewer-1.0.5_11
        Re-installation of R-cran-RMySQL-0.9.3_8
        Re-installation of R-cran-colorspace-1.2.4_2
        Re-installation of R-cran-dichromat-2.0.0_4
        Re-installation of R-cran-digest-0.6.4
        Re-installation of R-cran-iterators-1.0.6_7
        Re-installation of R-cran-itertools-0.1.1_11
        Re-installation of R-cran-plyr-1.8_5
        Re-installation of R-cran-proto-0.3.10_5
        Re-installation of R-cran-stringr-0.6.2_5
        Re-installation of R-cran-reshape2-1.2.2_5
        Re-installation of R-cran-munsell-0.4.2_2
        Re-installation of R-cran-labeling-0.2_2
        Re-installation of R-cran-scales-0.2.3_5
        Re-installation of R-cran-gtable-0.1.2_5
        Re-installation of R-cran-ggplot2-0.9.3.1_4
        Re-installation of R-cran-zoo-1.7.10_2

===>>> Exiting

Folowing that, I trried running the script in an xterm without DISPLAY
defined; it worked as it had before.

As I type, I'm running it out of cron, and it's creating PNG files....

Evidently, I screwed up an update within the last few weeks, so my
allegation that this was something that had changed in R was not true.
I apologize if I mislead or offended anyone: I was wrong.

And "thank you" again to those who tried to help.

Peace,
david   (back to cloaked mode)
#
This is mostly a guess...

At the end of January, your script succeeded.
Your OS was "built Sun Feb 23 05:14:37 PST 2014."
Your script failed on Feb 26.
You probably had not made any changes to R between the end of January and
Feb 26 (I don't see any mention of having done so, and R does not update
itself -- unless you have some OS level package manager that does it for
you; I wouldn't know about that).

At this point, I'd wonder if the OS update on 2/23 changed come libraries
that R relies on for png graphics. Perhaps you need to rebuild R, so that
it uses the changed/updated OS libraries. Hopefully that OS update did not
completely remove libraries that R depends on for png.

-Don