[Rd] png error

Terry Therneau terry@therne@u @end|ng |rom proton@me
Wed Sep 9 16:51:02 CEST 2026


Responding to some of the suggestions.
1. I think that Cairo is enabled.  Here is the final bit from configure in src/R-devel on my machine:

R is now configured for x86_64-pc-linux-gnu

  Source directory:            .
  Installation directory:      /usr/local

  C compiler:                  gcc -std=gnu2x  -g -O2
  Fortran fixed-form compiler: gfortran  -g -O2

  Default C++ compiler:        g++ -std=gnu++20  -g -O2
  Fortran free-form compiler:  gfortran  -g -O2
  Obj-C compiler:	        

  Interfaces supported:        X11, tcltk
  External libraries:          pcre2, readline, curl, libdeflate
  Additional capabilities:     PNG, JPEG, TIFF, NLS, cairo, ICU
  Options enabled:             shared BLAS, R profiling, libdeflate for lazyload

  Capabilities skipped:        
  Options not enabled:         memory profiling

  Recommended packages:        yes

2. THis fails using either 
   R CMD BATCH checkdep3.R or 
   R --no-save < checkdep3.R
and here is the heart of that script
-------------
#... lines to create 'survdep', the list of things to check
xvfb_options <- "-screen 0 1280x1024x24"
pid <- tools:::start_virtual_X11_fb(options= xvfb_options)
on.exit(tools:::close_virtual_X11_db(pid), add = TRUE)
 
setwd("xtest")
system("rm -rf *.gz")
# don't fail a test due to a missing 'suggested' package.  This matches what
#  CRAN does
Sys.setenv("_R_CHECK_FORCE_SUGGESTS_"=FALSE) 
                                            
for (i in survdep) {
    cat(i, "\n")
    download.packages(i, ".", type="source")
    system(paste0("R CMD check ", i, "*.gz"))
    cat("\n")
}
setwd("..")
---------------
Here is a standard error (from frailtyEM)
-------------
> ggplotly(pl2)
Warning in dev_fun(filename = tempfile(), width = width %||% 640, height = heigh
t %||%  :
  unable to open connection to X11 display ''
Error in .External2(C_X11, paste0("png::", filename), g$width, g$height,  : 
  unable to start device PNG
Calls: ggplotly -> ggplotly.ggplot -> gg2list -> dev_fun
Execution halted
------------

3. Here is the result of a script that replaces the for loop above
with the suggested display command

--------
R --no-save < test.R
> xvfb_options <- "-screen 0 1280x1024x24"
> pid <- tools:::start_virtual_X11_fb(options= xvfb_options)
> on.exit(tools:::close_virtual_X11_db(pid), add = TRUE)
>  
> setwd("xtest")
> # don't fail a test due to a missing 'suggested' package.  This matches what
> #  CRAN does
> Sys.setenv("_R_CHECK_FORCE_SUGGESTS_"=FALSE) 
>      
> Sys.getenv("DISPLAY")
[1] ":3675973"
>
-------------

Terry

On Saturday, September 5th, 2026 at 12:29 PM, Ivan Krylov <krylov.r00t using gmail.com> wrote:

> On Sat, 05 Sep 2026 16:30:10 +0000
> Terry Therneau via R-devel <r-devel using r-project.org> wrote:
> 
> > unable to open connection to X11 display ''
> > Error in .External2(C_X11, paste0("png::", filename), g$width,
> > g$height, : unable to start device PNG
> 
> This is a little strange because normally R would prefer to use the
> Cairo-based device that doesn't require an X server connection. Did you
> intend for your build of R to skip using Cairo?
> 
> If you're interested in debugging, see if Sys.getenv("DISPLAY") returns
> anything useful after you attempt to start Xvfb. Can you run
> DISPLAY=$that_string xeyes? Is the socket in present in /tmp/.X11-unix/?
> 
> You could also try to run 'xvfb-run R' and then skip starting Xvfb by
> hand. Does 'xvfb-run R CMD check frailtyEM_*.tar.gz' work?
> 
> --
> Best regards,
> Ivan
>



More information about the R-devel mailing list