R refers to non exisiting files during R CMD check - r

I want to R CMD check with RStudio my package (for this question I call it pkg). But I get the following error message:
* preparing 'pkg':
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ...Error in find_vignette_product(name, by = "weave", dir = docdir, engine = engine) :
Failed to locate the 'weave' output file (by engine 'utils::Sweave') for vignette with name 'my-vignette'. The following files exist in directory 'C:/Users/name/AppData/Local/Temp/RtmpQLnSjE/Rbuild244434d45c05/pkg/vignettes': 'my-vignette.R', 'my-vignette.Rmd'
Execution halted
Error: Command failed (1)
In addition: Warning message:
`cleanup` is deprecated
Execution halted
Exited with status 1.
One first thing, where something might got wrong is that there is no folder called RtmpQLnSjE in my C:/Users/name/AppData/Local/Temp/ directory. Running my Rmd file by hand, does not generate any errors.
I update RStudio to the latest version 1.1.423 and this is my SessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MCMCglmm_2.25 ape_5.0 coda_0.19-1 lme4_1.1-15 Rcpp_0.12.15 Matrix_1.2-12 hmi_0.9.4
loaded via a namespace (and not attached):
[1] lattice_0.20-35 corpcor_1.6.9 digest_0.6.15 withr_2.1.1 MASS_7.3-48 grid_3.4.3
[7] nlme_3.1-131 cubature_1.3-11 minqa_1.2.4 nloptr_1.0.4 devtools_1.13.4 splines_3.4.3
[13] tools_3.4.3 yaml_2.1.16 parallel_3.4.3 compiler_3.4.3 memoise_1.1.0 tensorA_0.36

Concluding as an answer:
Failed to locate the 'weave' output file
This error can have several root causes and is not always easy to trace down. However, there is a good chance that it is related to code inside the vignette, in particular code navigating directories and such (e.g. setwd() or other functions that may rely on relative paths that could differ between a stand-alone run and the more involved R CMD check)

I recently ran across this when a vignette file had a space in the name (like "My Vignette.Rmd"). It was creating an html file called My-Vignette.html. I think it's the hyphen in the name that was causing issues (based on the answer above along with what I'm seeing.)

Related

Error in inla.call.builtin() : INLA installation error; no such file

I have recently updated INLA using the inla.update on my machine. Now everytime I try to run a function from the package, such as inla.mesh.2d I obtain the following error:
Error in inla.call.builtin() : INLA installation error; no such file
I tried uninstalling and reinstalling INLA package both in its testing and stable version but it still won't work.
I will paste below the output from sessionInfo():
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] it_IT.UTF-8/it_IT.UTF-8/it_IT.UTF-8/C/it_IT.UTF-8/it_IT.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] INLA_22.01.16 sp_1.4-5 foreach_1.5.1 Matrix_1.3-4
loaded via a namespace (and not attached):
[1] compiler_4.0.3 tools_4.0.3 tinytex_0.32 splines_4.0.3 codetools_0.2-18 grid_4.0.3
[7] iterators_1.0.13 xfun_0.23 lattice_0.20-44
Thank You!
The error you are getting may solve if you update your R to its latest version so INLA requirements are met. Restart, and it may resolve.
If this does not resolve the problem, installing directly from the R interface (vs RStudio) might fix the problem. This link explains how it is done and might be helpful if the first solution did not help.
https://groups.google.com/g/r-inla-discussion-group/c/f3LAE2VHZQw

Trouble with downloading certain packages from github in R

I get an error when I try to download and install some packages from github on my Mac, e.g. lubripack. How do I locate what the error actually means? And how to solve it?
I run: install_github("Espanta/lubripack"). I have tried with different libpaths and with force=TRUE.
This is from the console:
checking for file
‘/private/var/folders/nc/vs1bpbqn095bbx84qcwwm4bm0000gn/T/RtmpMn5l2o/remotes8cb7b2460a1/Espanta-lubripack-b1dd9ee/DESCRIPTION’
... OK preparing ‘lubripack’: checking DESCRIPTION meta-information
... OK checking for LF line-endings in source and make files and shell
scripts checking for empty or unneeded directories building
‘lubripack_0.1.tar.gz’ Error: Failed to install 'lubripack' from
GitHub: (converted from warning) line 1 appears to contain an
embedded nul
You may not need to worry about installing the package from github - since the package only contains a single function, I'd simply copy the code for that function and use it (citing the author if/when appropriate).
lubripack <- function(...,silent=FALSE){
#check names and run 'require' function over if the given package is installed
requirePkg<- function(pkg){if(length(setdiff(pkg,rownames(installed.packages())))==0)
require(pkg, quietly = TRUE,character.only = TRUE)
}
# list of packages to install and load
packages <- as.vector(unlist(list(...)))
if(!is.character(packages))stop("No numeric allowed! Input must contain package names to install and load")
if (length(setdiff(packages,rownames(installed.packages()))) > 0 )
install.packages(setdiff(packages,rownames(installed.packages())),
repos = c("https://cran.revolutionanalytics.com/", "http://owi.usgs.gov/R/"))
res<- unlist(sapply(packages, requirePkg))
if(silent == FALSE && !is.null(res)) {cat("\nBellow Packages Successfully Installed:\n\n")
print(res)
}
}
It works for me even on R 4.0.2
lubripack(list("dplyr"))
Bellow Packages Successfully Installed:
dplyr
TRUE
And for reference
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.0.0 gtools_3.8.2
loaded via a namespace (and not attached):
[1] crayon_1.3.4 R6_2.4.1 lifecycle_0.2.0 magrittr_1.5 pillar_1.4.6 rlang_0.4.7 rstudioapi_0.11 vctrs_0.3.2
[9] generics_0.0.2 ellipsis_0.3.1 tools_4.0.2 glue_1.4.1 purrr_0.3.4 compiler_4.0.2 pkgconfig_2.0.3 tidyselect_1.1.0
[17] tibble_3.0.3
Try this
First run
install.packages("remotes")
once done
Run this : -
remotes::install_github("Espanta/lubripack")
Ignore the warning
I am able to load the library
I am not sure if this library is up to date like Dirk Eddelbuettel mentioned
But its loading

object 'pkgInfo' not found, r

I'm trying to run a script that worked well in the past few days, but has been causing me much grief recently.
When I try to load the caret library, it says that there is a problem with ggplot2. Here is the output:
> library(caret)
Loading required package: lattice
Loading required package: ggplot2
Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
object 'pkgInfo' not found
Error: package ‘ggplot2’ could not be loaded
I have no clue what pkgInfo is. Other StackOverflow questions answers to this problem are that that's from not using quotes in your code making R think that it's looking for an object named pkgInfo. But in this case, the error is coming from inside...
...the source code of ggplot2. (maybe, I don't know, it's not my code directly causing the error I know) I've ran install.packages("ggplot", dep = TRUE) and it fixed the problem for now, but I want a longer solution. I'm pretty sure I tried that yesterday and left me to still need to fix it today. I'd also like an explanation if y'all can provide so I can prevent this in the future. Thanks!
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lattice_0.20-35
loaded via a namespace (and not attached):
[1] compiler_3.5.1 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2 htmltools_0.3.6 tools_3.5.1 yaml_2.2.0
[8] Rcpp_0.12.18 stringi_1.1.7 rmarkdown_1.10 grid_3.5.1 knitr_1.20 stringr_1.3.1 digest_0.6.15
[15] evaluate_0.11
I think it is caret, since caret is wrapper to a lot R package, caret does not use the traditional package dependency process in R, if it did caret would require the install of a lot of packages.
https://cran.r-project.org/web/packages/caret/vignettes/caret.html
You can force it by
install.packages("caret", dependencies = c("Depends", "Suggests"))
The following slide deck (by Max Kuhn, and Zachary Deane-Mayer) explains it a lot better than I could.
https://www.slideshare.net/sermakarevich/odscbos2015maxkhun-150601094910lva1app6892
In the package DESCRIPTION
The Imports section lists packages that may be loaded at run time.
Suggests are packages that may be used but are not required, and Depends are packages that are loaded as soon as caret is loaded
ggplot2 is listed under the Depends section in caret
https://github.com/topepo/caret/blob/master/pkg/caret/DESCRIPTION
I am sorry for posting misleading info, a red herring.
My working directory for R is in my Documents folder. My Documents folder is synced to my google drive, and I noticed a few days ago that google drive was working very hard, sucking up some resources in the background. I saw that a lot of the files it was trying to sync was in the win-library directory for R. I, not knowing how to truly stop the syncing of a subdirectory, deleted the directory from my google drive expecting it to stop messing with my R on my laptop.
Instead, Google started messing with my R files even more. Now that I've stopped syncing my Documents folder with Google Drive, everything is running smoothly.

Re-initialize with packrat::init()

I have no idea how to make this problem reproducible, but here is a description of the problem nevertheless. I upgraded to R v 3.4.0 yesterday (sessionInfo() is below) and one of my RStudio projects couldn't update packages in packrat. After messing around with various "fixes" without success, I decided to delete packrat (packrat directory, project dir's .RStudio file) in the end. Unfortunately, I can't seem to re-initialize packrat in this project now. The following is the R output from
> packrat::init()
Initializing packrat project in directory:
- "~/my-project-path"
Error in isNamespaceLoaded(pkg) :
attempt to use zero-length variable name
In addition: Warning message:
In FUN(X[[i]], ...) : Package '' not available in repository or locally
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.0 magrittr_1.5 tools_3.4.0 yaml_2.1.14 stringi_1.1.5
[6] knitr_1.15.1 stringr_1.2.0 packrat_0.4.8-1 evaluate_0.10
Any help is very much appreciated. I thought about re-cloning the repo from github, but that would involve copy a large amount of files over from various directories that aren't under revision control currently.
Thanks!

Enable travis CI to check for package dependencies

Actual question
What do I need to do in order to enable travis CI to check my package dependencies?
What I tried
I tried adding the cran argument to .travis.yml file as describe in guide on travis-ci.com.
My .travis.yml file looks like this:
language: r
warnings_are_errors: yes
sudo: required
cran: http://cran.rstudio.com
r_packages:
- covr
after_success:
- Rscript -e 'covr::codecov()'
Yet, I still get the following error:
* checking package dependencies ... ERROR
No repository set, so cyclic dependency check skipped
Session info
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devops_0.1.2
loaded via a namespace (and not attached):
[1] magrittr_1.5 tools_3.2.2 yaml_2.1.13 memoise_0.2.1 stringi_1.0-1
[6] stringr_1.0.0 digest_0.6.8 devtools_1.9.1
Update
I found out that the error was actually cause by listing some package dependencies in Suggests: instead of Imports: section of my DESCRIPTION file (build that passed).
However, I'm still getting a note that the dependency check was skipped as no repository has been set:
* checking package dependencies ... NOTE
No repository set, so cyclic dependency check skipped
Does that mean that a dependency check has not been carried out and, if so, what do I need to change in order to make this happen?

Resources