[Rd] capabilities(), was [R-pkg-devel] ... No protocol specified (OS X only)

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Fri Feb 21 09:53:16 CET 2020


Diverting (from R-package-devel) to R-devel, as it is now about
extending R :

>>>>> Jeroen Ooms   on Thu, 20 Feb 2020 20:34:14 +0100 writes:

    > On Tue, Feb 18, 2020 at 1:29 AM Dominic Comtois
    > <dominic.comtois using gmail.com> wrote:
    >> 
    >> Hello,
    >> 
    >> On my package's check results (
    >> https://cran.r-project.org/web/checks/check_results_summarytools.html), I
    >> see a bunch of warnings with "No protocol specified" messages. This happens
    >> only with OS X, and I can't reproduce them when actually building on a Mac,
    >> nor with rhub::check_on_macos(). I can't really make sense out of them, and
    >> they are all over the place. Can they simply be ignored?

    > This happens when your package calls capabilities(), which as a side
    > effect initiates xquartz. It seems the MacOS server has certain
    > permission restrictions that cause X11 to print this warning.

    > I think you can safely ignore it.

Thank you, Jeroen.

The function is currently defined (in base/R/New-Internal.R ) as

capabilities <- function(what = NULL)
{
    z  <- .Internal(capabilities())
    if(!is.null(what))
        z <- z[match(what, names(z), 0L)]
    if(.Platform$OS.type == "windows") return(z)
    ## Now we need to deal with any NA entries if X11 is unknown.
    nas <- names(z[is.na(z)])
    if(any(nas %in% c("X11", "jpeg", "png", "tiff"))) {
        ## This might throw an X11 error
         z[nas] <- tryCatch(.Internal(capabilitiesX11()),
                            error = function(e) FALSE)
    }
    z
}

and we could easily add a 2nd argument, say  'Xchk = TRUE'  like
this

capabilities <- function(what = NULL, Xchk = TRUE)
{
    z  <- .Internal(capabilities())
    if(!is.null(what))
        z <- z[match(what, names(z), 0L)]
    if(.Platform$OS.type == "windows") return(z)
    if(Xchk) {
	## Now we need to deal with any NA entries if X11 is unknown.
	nas <- names(z[is.na(z)])
	if(any(nas %in% c("X11", "jpeg", "png", "tiff"))) {
	    ## This might throw an X11 error
	     z[nas] <- tryCatch(.Internal(capabilitiesX11()),
				error = function(e) FALSE)
	}
    }
    z
}

and as an afterthought rather improve the argument's default, from

    Xchk = TRUE

to

    Xchk = is.null(what) ||
           any(c("X11", "jpeg", "png", "tiff") %in% what)

(or similar smart defaults).

Then, e.g.,  capabilities("long.double")  or
capabilities("profmem")
would never trigger that X11-lookup and neither would

  cap <- capabilities(X = FALSE)

where you'd typically get an  NA  for cap[["X11"]]


Martin



More information about the R-devel mailing list