Installing package fails when building vignettes ((..)/doc/index.html is missing)
Asked Answered
D

4

12

I'm creating an R package with a vignette. However, when I try to install the package by using

 devtools::install(build_vignettes = TRUE)

an error occurs since it cannot find the file index.html in the doc folder. I thought this file would be automatically created, but apperently something goes wrong here. The error occuring is the following:

"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" --no-site-file --no-environ --no-save --no-restore  \
--quiet CMD INSTALL "C:/Users/lnab/AppData/Local/Temp/Rtmpi0XLJ4/mecor_0.1.0.tar.gz"  \
--library="\\vf-d2-home/d2home$/lnab/MyDocs/R/win-library/3.4" --install-tests 

* installing *source* package 'mecor' ...
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
converting help for package 'mecor'
finding HTML links ... done
mecor-package                           html  
uaetrial                                html  
uaetrial_cal                            html  
** building package indices
** installing vignettes
Warning in file(con, "w") :
cannot open file '\\vf-d2-home/d2home$/lnab/MyDocs/R/win-library/3.4/mecor/doc/index.html': No such file or directory
Error in file(con, "w") : cannot open the connection
ERROR: installing vignettes failed
* removing '\\vf-d2-home/d2home$/lnab/MyDocs/R/win-library/3.4/mecor'
* restoring previous '\\vf-d2-home/d2home$/lnab/MyDocs/R/win-library/3.4/mecor'
In R CMD INSTALL

My vignette .Rmd looks like this:

---
title: "Introduction to mecor"
author: "Linda Nab"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction to mecor}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---  

I never build an R package before but search the internet for a solution for this problem for days but cannot find any. This seems to be the same problem but I cannot find the solution for the problem there. You can find my package here.

Really hope someone could help me!

Doralyn answered 9/1, 2018 at 14:26 Comment(6)
Try mapping the network drive, so the library is at something like W://lnab/MyDocs/R/win-library/3.4/mecor instead of the network share \\vf-d2-home/d2hoem$/...Coulomb
Thanks. I mapped the network drive by changing the variable .libPaths to H:/MyDocs/R/win-library/3.4. Unfortunatelly, the same error is produced when installing the package.Doralyn
In addition, the package check now also fails, producing the same error: 'Warning in file(con, "w") : cannot open file 'H:/mecor.Rcheck/mecor/doc/index.html': No such file or directory Error in file(con, "w") : cannot open the connection ERROR: installing vignettes failed'. Before changing the path of the library, the check did not fail.Doralyn
It looks like you are building from the tar.gz which may have been built without vignette. Perhaps try run directly on the package: open mecor project file and run devtools::install(build_vignettes = TRUE)Staggers
I succeeded in building the package with the vignettes! I had to remove the folder /inst where in the subfolder /doc the .R, .html and .Rmd of my vignette were stored after using devtools::build_vignettes() (I used this earlier when trying to find a solution for my problem). I guess mapping the network drive together with removing this folder ended up in a solution for my problem. Many thanks!Doralyn
I still have this problem! The fixes I found do not work. In particular, I tried: 1. Reverse the .gitignore as it was before the bug 2. This: .onLoad() 3. This: Hadley ..Rcheck Moreover, in my case the bug is happening only during the checks and not in the build!Chlamydeous
P
5

I had /inst/ and .git in my .Rbuildignore file. When I removed those two lines from .Rbuildignore the vignettes built properly.

Protist answered 31/7, 2019 at 18:37 Comment(1)
I had this problem. In my .Rbuildignore file, someone, had put inst/doc. Once I removed it the error dissapeared.Dachia
G
4

It took me a few days, but in my case it worked once I removed a folder called "build". I am happy now! Previously, my check worked but not my install.

Gauzy answered 16/9, 2021 at 13:45 Comment(0)
G
3

I also found and followed all the problems Garini notes on a comment:

  1. Reverse the .gitignore as it was before the bug
  2. This: [.onLoad()][1]
  3. This: Hadley ..Rcheck

What worked for me was to check for other folders and files on the directory of the package and remove or ignore at building those folders that are not standard for an R package, for a summary of them see the index of R packages. This is on line with the Hadley proposed solution. Maybe is a folder or file created by the vignette or while developing the package.

In my case I had a build folder I didn't realize it was there.

Gaspard answered 21/12, 2018 at 10:51 Comment(0)
L
0

At some point, I made the dumb mistake of adding doc to .Rbuildignore. That generated the same error described here. Removing doc from .Rbuildignore solved the issue for me.

Lindner answered 16/7, 2021 at 18:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.