Henrik Bengtsson
2017-Aug-29 23:19 UTC
[Rd] BUG: HMTL-based help.search() on vignettes may generate error (with PATCH)
REPRODUCIBLE EXAMPLE: With the R.rsp package installed, the following search, which gives a hit: options(help_type = "html") help.search("rsp") generates: Error in if (nchar(Outfile)) Outfile else File : argument is not interpretable as logical in the browser (e.g. http://127.0.0.1:30410/doc/html/Search?results=1). Another example is help.search("tm") with jsonlite installed. TROUBLESHOOTING: This occurs because utils:::merge_vignette_index() uses: base[, "Name"] <- sub("\\.[^.]*$", "", basename(vDB$File)) base[, "Topic"] <- base[, "Name"] which assumes that the 'Name' (and hence the 'Topic') can be inferred from the basename of the vignette source file by dropping the filename extension. This assumption was valid in R (< 3.0.0), but with the introduction of generic vignette engines, we may now have multiple ("nested") file-name extensions on vignette source files. For instance, vignette source file 'vignette.tex.rsp' outputs 'vignette.pdf'. Another example is 'vignette.pdf.asis' that outputs 'vignette.pdf'. Now, the assumption on a single file-name extension is still valid on the vignette output product file, where we can only have file name extensions *.pdf and *.html. Because of this, a solution is to use 'basename(vDB$PDF)' instead of 'basename(vDB$File)'. This is also what tools:::httpd() uses internally and the difference between the two approach is what causes the error in help.search() above. PATCH: A patch (against R-devel) is: svn diff src/library/utils/R/help.search.R Index: src/library/utils/R/help.search.R ==================================================================--- src/library/utils/R/help.search.R (revision 73159) +++ src/library/utils/R/help.search.R (working copy) @@ -43,7 +43,7 @@ base[, "LibPath"] <- path id <- as.character(1:nrow(vDB) + NROW(hDB[[1L]])) base[, "ID"] <- id - base[, "Name"] <- sub("\\.[^.]*$", "", basename(vDB$File)) + base[, "Name"] <- tools::file_path_sans_ext(basename(vDB$PDF)) base[, "Topic"] <- base[, "Name"] base[, "Title"] <- vDB$Title base[, "Type"] <- "vignette" I have verified that the above patch solves the problem. I thought it is ok to use tools::file_path_sans_ext() since other functions in 'utils' already do so. I'm happy to submit this one via https://bugs.r-project.org/bugzilla3/ as well. APPENDIX:> sessionInfo()R version 3.4.1 (2017-06-30) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.3 LTS Matrix products: default BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0 LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.4.1 /Henrik
Henrik Bengtsson
2017-Sep-01 15:28 UTC
[Rd] BUG: HMTL-based help.search() on vignettes may generate error (with PATCH)
UPDATE: This has been fixed in R-devel (rev 73170) by Kurt H. I checked with him and he'll also try to get it into the upcoming R 3.4.2 (ETA 2017-09-28). /Henrik On Tue, Aug 29, 2017 at 4:19 PM, Henrik Bengtsson <henrik.bengtsson at gmail.com> wrote:> REPRODUCIBLE EXAMPLE: > > With the R.rsp package installed, the following search, which gives a hit: > > options(help_type = "html") > help.search("rsp") > > generates: > > Error in if (nchar(Outfile)) Outfile else File : > argument is not interpretable as logical > > in the browser (e.g. http://127.0.0.1:30410/doc/html/Search?results=1). > > Another example is help.search("tm") with jsonlite installed. > > > TROUBLESHOOTING: > > This occurs because utils:::merge_vignette_index() uses: > > base[, "Name"] <- sub("\\.[^.]*$", "", basename(vDB$File)) > base[, "Topic"] <- base[, "Name"] > > which assumes that the 'Name' (and hence the 'Topic') can be inferred > from the basename of the vignette source file by dropping the filename > extension. This assumption was valid in R (< 3.0.0), but with the > introduction of generic vignette engines, we may now have multiple > ("nested") file-name extensions on vignette source files. For > instance, vignette source file 'vignette.tex.rsp' outputs > 'vignette.pdf'. Another example is 'vignette.pdf.asis' that outputs > 'vignette.pdf'. > > Now, the assumption on a single file-name extension is still valid on > the vignette output product file, where we can only have file name > extensions *.pdf and *.html. Because of this, a solution is to use > 'basename(vDB$PDF)' instead of 'basename(vDB$File)'. This is also > what tools:::httpd() uses internally and the difference between the > two approach is what causes the error in help.search() above. > > > PATCH: > > A patch (against R-devel) is: > > svn diff src/library/utils/R/help.search.R > Index: src/library/utils/R/help.search.R > ==================================================================> --- src/library/utils/R/help.search.R (revision 73159) > +++ src/library/utils/R/help.search.R (working copy) > @@ -43,7 +43,7 @@ > base[, "LibPath"] <- path > id <- as.character(1:nrow(vDB) + NROW(hDB[[1L]])) > base[, "ID"] <- id > - base[, "Name"] <- sub("\\.[^.]*$", "", basename(vDB$File)) > + base[, "Name"] <- tools::file_path_sans_ext(basename(vDB$PDF)) > base[, "Topic"] <- base[, "Name"] > base[, "Title"] <- vDB$Title > base[, "Type"] <- "vignette" > > I have verified that the above patch solves the problem. I thought it > is ok to use tools::file_path_sans_ext() since other functions in > 'utils' already do so. > > I'm happy to submit this one via https://bugs.r-project.org/bugzilla3/ as well. > > > APPENDIX: > >> sessionInfo() > R version 3.4.1 (2017-06-30) > Platform: x86_64-pc-linux-gnu (64-bit) > Running under: Ubuntu 16.04.3 LTS > > Matrix products: default > BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0 > LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0 > > locale: > [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C > [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 > [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 > [7] LC_PAPER=en_US.UTF-8 LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > loaded via a namespace (and not attached): > [1] compiler_3.4.1 > > /Henrik