CRAN check: warning vignette engine knitr::rmarkdown is not available - r

I'm trying for the first time to add some vignettes in my package. Everything is ok on my computer. No warning, no error. Then I uploaded it to the CRAN windows builder
devtools::check_win_release()
And I got this warning relative to vignettes:
* checking re-building of vignette outputs ... [7s] WARNING
Error in re-building vignettes:
...
Warning in engine$weave(file, quiet = quiet, encoding = enc) :
The vignette engine knitr::rmarkdown is not available, because the rmarkdown package is not installed. Please install it.
Failed with error: 'there is no package called 'rmarkdown''
Quitting from lines 172-178 (las.Rmd)
Error: processing vignette 'las.Rmd' failed with diagnostics:
cannot open the connection
Execution halted
I don't think that this issue is related to the content of the package. Can I assume that it is an "ok" warning? Can I fix it?
My DESCRIPTION file contains:
Suggests: knitr
VignetteBuilder: knitr
My vignettes/ folder contains one Rmd file
My inst/doc/ folder contains the Rmd R and html auto generated files relative the the original Rmd file.

You need to add rmarkdown in your Suggests.

Related

Cannot install vignette from an R package on GitHub

I coded an R package that is hosted on my GitHub. I included a vignette, and I can install the package and load the vignette without any issue from R and RStudio by doing:
devtools::install_github("rosalieb/serac", build_vignettes = TRUE)
library(serac)
vignette("serac")
However, I have a few colleagues who cannot install the vignette (the only way they can download the package is by doing devtools::install_github("rosalieb/serac") (default of build_vignettes is FALSE).
It works if they use RStudio, but not in 'regular' R.
I encourage people to use RStudio, but I cannot force them, and eventually, I do not understand why it would work in 'regular' R for me but not for them.
They tried to install pandoc, knitr, Rtools - none of these worked.
Here is the error message when my colleague tries to install the package with the vignette:
v checking for file 'C:\Temp\RtmpO8YwVb\remotesf9842f1431\rosalieb-serac-46a3587/DESCRIPTION'
- preparing 'serac':
checking DESCRIPTION meta-information ...
checking DESCRIPTION meta-information ...
v checking DESCRIPTION meta-information
- installing the package to build vignettes
creating vignettes ...
creating vignettes ...
E creating vignettes (4.9s)
--- re-building 'serac.Rmd' using rmarkdown
Error: processing vignette 'serac.Rmd' failed with diagnostics:
Pandoc is required to build R Markdown vignettes but not available. Please make sure it is installed.
--- failed re-building 'serac.Rmd'
RESUME : le traitement du fichier suivant a échoué :
'serac.Rmd'
Erreur : Vignette re-building failed.
Exécution arrêtée
Erreur : Failed to install 'serac' from GitHub:
System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed
Thanks in advance for your help!
The message indicates that rmarkdown::render can't find Pandoc.
It looks for it in three places: in the directory specified by the RSTUDIO_PANDOC environment variable, in directories on the PATH, in the directory opt/pandoc in the user's home directory. So your colleagues who have installed it should make sure it is available in one of those locations. They can see the current values of the environment variables by running
Sys.getenv("PATH")
and
Sys.getenv("RSTUDIO_PANDOC")
Temporary changes can be made using
Sys.setenv(RSTUDIO_PANDOC="/path/to/pandoc/directory")
This needs to happen in the session that is trying to install the package and build the vignette, not in the vignette itself.
How to make permanent changes to those values depends on the details of what system they are running.

Unable to knit rmd file in R studio. Receiving error that there is no "lmSupport" package but I am not loading in this package

I am trying to knit an .rmd file to pdf. I am receiving the following error message:
Error in library(lmSupport) : there is no package called ‘lmSupport’
Execution halted
lmsupport is not in my code at all. I tried restarting R and clearing cache. Not sure what else to do.
I have the most recent version of R downloaded on my Mac

Insallation failed on devtools::install_github("rstudio/rmarkdown")

I use R 3.4.3, And I need to install devtools::install_github("rstudio/rmarkdown"). But the following installation error comes up.
Downloading GitHub repo rstudio/rmarkdown#master
from URL https://api.github.com/repos/rstudio/rmarkdown/zipball/master
Installation failed: zip file 'C:\Users\Buster\AppData\Local\Temp\RtmpWyl4FP\file3bc6c571eec.zip' cannot be opened
Warning messages:
1: GitHub repo contains submodules, may not function as expected!
2: In utils::unzip(src, exdir = target) :
error 1 in extracting from zip file
How can I install this?
this has been resolved. I used devtools::install_url("http://cran.r-project.org/src/contrib/rmarkdown_1.9.tar.gz")
As explained in the README for rmarkdown:
If you are working within RStudio then you can simply install the
current release of RStudio (both the rmarkdown package and pandoc are
included).
If you want to use the rmarkdown package outside of RStudio then you
can install the package from CRAN as follows:
install.packages("rmarkdown")
This is a much more concise way of doing:
devtools::install_url("http://cran.r-project.org/src/contrib/rmarkdown_1.9.tar.gz")

Pandoc not recognized as R library

I installed Pandoc manually through this installation - link.
After restarting the system, I was able to locate the installation folder at C:/Users/YourUserName/AppData/Local/Pandoc
But when I'm trying to call the library:
library("pandoc", lib.loc = "C:/Users/YourUserName/AppData/Local/Pandoc")
I'm getting the following error:
Error in library("pandoc", lib.loc = "C:/Users/YourUserName/AppData/Local/Pandoc") :
no library trees found in 'lib.loc'
As i'm behind a firewall, I cannot install pandoc through github. So the install.pandoc() function is out.
Any ideas where I'm getting the installation process wrong?
Edit:
I've changed .LibPath to point to Pandoc's installation folder:
.libPaths('C:/Users/stefanj/AppData/Local/Pandoc')
And if I check, it seems to be ok:
> grep("pandoc", list.files(.libPaths()))
[1] 22 24
library(pandoc)
Error in library(pandoc) : there is no package called ‘pandoc’
Execution halted
I agree to #Dason's point that library in path : "C:/Users/YourUserName/AppData/Local/Pandoc" is not any library/package connected with R. It's just pandoc installed.
Other way to install pandoc would be using installr :
installr::install.pandoc()
Now, for performing for converting from one markup format to another, use the following package :
rmarkdown
The rmarkdown package includes high level functions for converting to a variety of formats. For
example:
render("input.Rmd", html_document())
render("input.Rmd", pdf_document())
Hope this helps.

Cannot install my created packages

I've been writing a lot of code for my personal use and finally reached a point where I realised I should really be including this all in a package which I can load in instead of copy and pasting it in each time.
I followed the following tutorial for the creation of a basic package.
https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/
As far as I can tell everything went well with the actual creation element. Here are screenshots of the result:
The cats folder:
The /cats/R folder
The /cats/man folder
The problem comes when I want to run the line:
install("cats")
When I try to do that I get the following error:
Installing cats
"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL "/Documents/cats" --library="C:/Users/Aodhán/Documents/R/win-library/3.3" --install-tests
* installing *source* package 'cats' ...
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/Aodhán/Documents/R/win-library/3.3/cats/DESCRIPTION': No such file or directory
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'cats'
* removing 'C:/Users/Aodhán/Documents/R/win-library/3.3/cats'
Error: Command failed (1)
This error happens for my own package, but it also happens if I run the command:
devtools::install_github("klutometis/roxygen")
Any advice would be appreciated.
EDIT: Could it be that my username contains the character á in it?
EDIT 2:The DESCRIPTION file is:
Package: cats
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors#R: person("First", "Last", email = "first.last#example.com",
role = c("aut", "cre"))
Maintainer: Aodhán O'Leary
Author: Aodhán O'Leary [aut, cre]
Description: What the package does (one paragraph).
Depends: R (>= 3.3.1)
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Sys.getenv("R_HOME") returns "C:/PROGRA~1/R/R-33~1.1"
Sys.getenv("R_LIBS_USER") returns "C:\Users\Aodhán\Documents/R/win-library/3.3"
Sys.getenv("R_HOME") returns "C:\Users\Aodhán\Documents"
devtools::build("cats") creates "cats_0.0.0.9000.tar.gz"
install.packages("../cats_version.tar.gz") returns the same error as above
Note: This is on a Win10 machine, using R 3.3.1, which I apologise for not mentioning up top. I was quite tired when writing the post yesterday.
Edit 3: Here's the result of using the following commands: R CMD build cats followed by R CMD check cats
00check:
using log directory 'C:/Users/Aodhán/Documents/cats.Rcheck'
using R version 3.3.1 (2016-06-21)
using platform: x86_64-w64-mingw32 (64-bit)
using session charset: ISO8859-1
checking for file 'cats/DESCRIPTION' ... OK
this is package 'cats' version '0.0.0.9000'
package encoding: UTF-8
checking package namespace information ... OK
checking package dependencies ... OK
checking if this is a source package ... OK
checking if there is a namespace ... OK
checking for .dll and .exe files ... OK
checking for hidden files and directories ... NOTE Found the following hidden files and directories: .gitignore These were most
likely included in error. See section 'Package structure' in the
'Writing R Extensions' manual.
checking for portable file names ... OK
checking whether package 'cats' can be installed ... ERROR Installation failed. See
'C:/Users/Aodhán/Documents/cats.Rcheck/00install.out' for details.
DONE
Status: 1 ERROR, 1 NOTE
00install.out
installing source package 'cats' ...
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/Aodhan/Documents/cats.Rcheck/cats/DESCRIPTION':
No such file or directory
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'cats'
removing 'C:/Users/Aodhán/Documents/cats.Rcheck/cats'
The problem was the special character in my name, á. When I put it in the C:\ directory and ran R CMD build cats and R CMD check cats it passed that error (though there was an error later on with the pdf - I'll see if I can resolve that myself).
I'll try and post this as a bug. Moderately annoying. Should have thought of that test earlier.
I've run into this problem recently (R version 3.5.2) on two different computers. I don't have the full, exact error message right now, but it contained the following two snippets:
Error in writeLines(paste0(c(out[is_not_empty]), eor), file, useBytes = useBytes) :
(converted from warning) invalid char string in output conversion
and
ERROR: installing package DESCRIPTION failed for package
The problem, I believe, was the existence of special characters in my .Rprofile file. I'd been meaning to get rid of that file anyway (for the sake of reproducibility), and doing so fixed the problem.
To do this in R, the code below will (1) copy your .Rprofile and save it as .Rprofile-old (in case you want to use/restore it later on) and then (2) delete your .Rprofile.
## copy backup of .Rprofile
file.copy("~/.Rprofile", "~/.Rprofile-old")
## delete .Rprofile
unlink("~/.Rprofile")
Once you've run the above code, restart R and the problem will [hopefully] be fixed!
Installing source package..
It is important to specify repo and type
Convert package into package_name.tar.gz
Get into project environment by double clicking the .Rproj file in
your project and click on build -> Build Source Package to build tar.gz file
install.packages("full_path/package_name.tar.gz", repo = NULL, type =
"source")

Resources