Closed dmurdoch closed 2 years ago
I forgot to mention it in the documentation, and will do it. Thanks for the report!
I don't want to add any hard dependencies to xfun. If other package authors want to use a function that requires other packages, they'd need to declare these packages as hard dependencies. However, if you don't use these packages directly, you will need a hack like https://github.com/atusy/minidown/commit/5761646d5a06f6fa406251542396c02b1eea5998 to avoid NOTEs in R CMD check
.
I think the docs would help, but a requireNamespace
test in base64_uri
(and the other functions using suggested packages) could give a more informative error message, e.g.
if (!requireNamespace("mime"))
stop("The base64_uri() function requires the mime package.")`.
Done. Thanks for the report!
Just a quick followup: xfun has its own mime_type()
function now, which does not have to depend on mime. It will use mime if available. If not, it will try some common MIME types defined in xfun:::mimemap
. If still not found, it will try tools:::mime_type()
. If that fails, it will resort to the command file --mime-type
on *unix and PowerShell on Windows.
In this code:
https://github.com/yihui/xfun/blob/096985d288b747381aeeca1aa1cd8ff2b9ff6db8/R/base64.R#L80-L82
we see an unconditional call to
mime::guess_type(x)
fromxfun::base64_uri()
, an exported function. Butmime
is not in theImports
list, just inSuggests
. There's a comment elsewhere (https://github.com/yihui/xfun/blob/f9ed8f7e0b3d544bd3c3a6cf9b204f515bcd8be4/R/markdown.R#L131) about a similar situation, but no comment here.The problem is that my in-development package (at https://github.com/rgl2gltf) fails automatic checks, because it only gets to
xfun
in the chain of dependencies, and that doesn't forcemime
to be installed.