[R-pkg-devel] katex

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Tue Apr 25 10:02:05 CEST 2023


On Mon, 24 Apr 2023 18:17:22 +0200
Göran Broström <gb using ehar.se> wrote:

>    cannot open file '/usr/lib/R/doc/html/katex/katex.js': No such
> file or directory

> I still get the error with R CMD check --as-cran. What am I
> missing? Obviously /usr/lib/R/doc/html/katex/katex.js (no 'doc'), but
> ...
> 
> I am installing R via apt.

Thank you for mentioning this detail!

At least in Debian packages, R's copy of KaTeX lives in /usr/share: per
Debian policy, "share" is for human-readable files like KaTeX, and
"lib" is for shared libraries, compiled code and the like.

For a copy of R built from source, it's not a problem:
file.path(R.home(), 'doc', 'html') does point to where KaTeX lives.

For a copy of R packaged into *.deb, the right path can be obtained
using file.path(R.home("doc"), "html"):

--- src/library/tools/R/utils.R (revision 84280)
+++ src/library/tools/R/utils.R (working copy)
@@ -1788,7 +1788,7 @@
     ctx <- NULL
     function() {
         if(is.null(fun) && requireNamespace("V8", quietly = TRUE)) {
-            dir <- file.path(R.home(), "doc", "html")
+            dir <- file.path(R.home("doc"), "html")
             ctx <<- V8::v8("window")
             ctx$source(file.path(dir, "katex", "katex.js"))
             ## Provides additional macros:

This path is also valid for an R build launched from source (without
"make install"). I don't know whether this would break a
differently-packaged build of R, though.

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list