R CMD Check, '--no-manual': How to change this option? - r

There are similar questions R create reference manual with R CMD check. However, I still can fix my problem with R CMD Check.
When R CMD Check, it indicates:
-- R CMD check results ----------------------------------- chest 0.0.1.0000 ----
Duration: 1m 32.1s
0 errors v | 0 warnings v | 0 notes v
R CMD check succeeded
But without producing the Reference Manual. When I check the log file, it says * using options '--no-manual --as-cran'. I have tried to change the Project option, then Build tools, then Check package R CMD check additional options without any success. What should I do to turn off --no-manual option? Thanks.

You appear to be running devtools::check() from the RStudio menus. I don't know if there's a way to set these options from the menus, but you can set them from the command line by running
devtools::check(manual = TRUE)

You can run R CMD check pkgtarfile, link, directly in a terminal, where pkgtarfile is the 'tar' file you obtain with devtools::build() or R CMD build pkgdirs. R CMD check generates the pdf manual by default and can be found in the folder pkgname.Rcheck.

Related

Building a package with devtools - throwing an error where "Author" and "Maintainer" fields are missing/empty despite being filled

In my DESCRIPTION file I have used the AUTHORS#R syntax to generate the Author and Maintainer fields, but in the R CMD Check process it keeps throwing an error message saying the fields are empty:
> checking for file 'bar/DESCRIPTION' ... ERROR
Required fields missing or empty:
'Author' 'Maintainer'
This was working previously so I don't know why it's not functioning now. I've saved the file, and rebuilt the pkg with "Clean and Rebuild". Alternatively I've tried filling the Author and Maintainer fields manually but that doesn't work either.
You need to run R CMD build on the repo then R CMD check on the resulting tarball.
A one liner which build and check the package.
R CMD BUILD . && R CMD CHECK $(ls -t . | head -n1)
a . means that sb already cd directory to the package one.
Both . (left and right) could be updated to PKGNAME if we are a one dir above.

Using RStudio's "Build" but no *.Rcheck generated

I've just started using RStudio's build check, and used it to make one package already. I've started on a second package, and this one is failing. As the build attempt happens, I get updates like:
* checking whether package ‘< package >’ can be installed ... ERROR
Installation failed.
See ‘/home/user/git/< package >.Rcheck/00install.out’ for details.
* DONE
Status: 1 ERROR
The problem is that the defined folder < package >.Rcheck doesn't exist, and neither do the files that are supposed to be in it (i.e. 00install.out, and 00check.log). Also, where I write < package >, the actual name of my package is shown instead.
I had folders view visible while the package was building, and I saw the .Rcheck folder appear, and then disappear shortly after. I was even able to browse the 000install.out file, but it had not yet encountered any errors.
It appears that the whole Rcheck folder is being removed when the build fails, leaving me with no trace of what caused the error.
Has anyone else experienced this? I'm using RStudio version 0.99.902 with R version 3.3.1 on Arch Linux.
My approach is the following one:
Go to 'Tools' -> 'Global Options' -> 'Packages' and then have a look, if 'View Rcheck directory after failed R CMD check' is ticked. You find other useful options there, too, e.g. 'Cleanup output after successful R CMD check'.
A little more detail on how to preserve error logs, based on the answer from #J_F. I needed to tick View Rcheck directory after failed R CMD check, because the cleanup occurs after the misleading message
See
‘.../yourpackage.Rcheck/00check.log’
for details.
I also needed to untick Cleanup output after successful R CMD check, because R CMD can succeed even when there are errors!
R CMD check results
1 error | 3 warnings | 2 notes
Warning messages:
1: `cleanup` is deprecated
2: Version of roxygen2 last used with this package is 6.0.1.9000. You only have version 6.0.1
R CMD check succeeded

CRAN Check: No repository set, so cyclic dependency check skipped [duplicate]

As of R 3.1.0 I get the following R check:
* checking package dependencies ... NOTE
No repository set, so cyclic dependency check skipped
I tried this advice: https://twitter.com/phylorich/status/431911660698083328
No go. I put the line options(repos="http://cran.rstudio.com/") in a .Rprofile in the package root directory. Still get the Note.
Also section 1.3.1 of Writing R Extensions states:
Some Windows users may need to set environment variable R_WIN_NO_JUNCTIONS
to a non-empty value. The test of cyclic declarations33in DESCRIPTION
files needs repositories (including CRAN) set: do this in ~/.Rprofile.
Is this possibly a result of the set environment variable R_WIN_NO_JUNCTIONS? If so how can I go about doing this? Any other possible causes of the note or suggested fixes?
From Writing R Extensions
The test of cyclic declarations in DESCRIPTION files needs repositories (including CRAN) set: do this in ~/.Rprofile, by e.g
options(repos = c(CRAN="http://cran.r-project.org"))
Recommended
User should double check if his .Rprofile is in his home and that it contains the mentioned option.
# in R session (any platform)
# where is my profile?
file.path(Sys.glob("~"),".Rprofile")
# is it there?
file.exists(file.path(Sys.glob("~"),".Rprofile"))
Or from R session using extra package:
library(pathological)
r_profile()
User should double check if the option entry is not nested in the IF condition, like in the following code:
# this will not help for R CMD check --as-cran
if(interactive()) {
options(repos = c(CRAN="http://cran.r-project.org"))
}
Dry run for any platform
Here is R script preparing easy temporary case of R package for testing, helping to faster find what is going wrong in your local usage.
This aproach helped myself to locate what was wrong in my .Rprofile file and generally can help to set up working initial state.
In best case, the check run should show only 1 NOTE about new submission.
first copy/paste the code and source it in your R session (--vanilla
preferably)
then run the command printed by the script to check test case --as-cran.
Example
# for example
R --vanilla -f makePackage.R
# here the resulting package path is as below
R --no-site-file CMD check --as-cran /tmp/pkgtest
# now see the check log
If your .Rprofile does not exist it will be created and one new line placed at the end of file in any case.
The makePackage.R script
# makePackage.R
# makes simple package for playing with check --as-cran
# copy this content to file makePackage.R
# then source it into your R --vanilla session
name <- "pkgtest"
#
# prepare and adjust package template
#
tempbase <- dirname(tempdir())
e <- new.env()
path <- dirname(tempdir())
# make simple package in path
e$fu <- function(){"Hello"}
package.skeleton(name=name,force=T,path=path,environment=e)
nil <- file.remove(
file.path(path,name,'Read-and-delete-me'),
file.path(path,name,'man',paste0(name,'-package.Rd'))
)
# adjust DESCRIPTION
D <- readLines(file.path(path,name,"DESCRIPTION"))
D[grepl("^Title: ",D)] <- "Title: Testing Skeleton"
D[grepl("^Author: ",D)] <- "Author: John Doe"
D[grepl("^Description: ",D)] <- "Description: Checking --as-cran check."
D[grepl("^Maintainer: ",D)] <- "Maintainer: John Doe <jdoe#doe.net>"
D[grepl("^License: ",D)] <- "License: GPL (>= 2)"
write(D,file.path(path,name,"DESCRIPTION"))
# make fu.Rd
write(
"\\name{fu}\\alias{fu}\\title{Prints}\\description{Prints}
\\usage{fu()}\\examples{fu()}",
file.path(path,name,'man','fu.Rd'))
#
# ensure that .Rprofile contains repos option
# add fresh new line et the end of .Rprofile
#
userRp <- file.path(Sys.glob("~"),".Rprofile")
write("options(repos = c(CRAN='http://cran.r-project.org'))",file=userRp, append=TRUE)
#
# print final message
#
msg <- sprintf("
Your test package was created in %s,
under name %s,
your user .Rprofile in %s was modified (option repos),
now check this test package from command line by command:
R --no-site-file CMD check --as-cran %s
", path, name, userRp, file.path(path,name)
)
# now is time to check the skeleton
message(msg)
Checking the package
# replace package-path by the path adviced by the sourcing the script above
R --no-site-file CMD check --as-cran package-path
There is user profile and site profile, in the approach above you bypasses site profile (in second step) by using --no-site-file option for package skeleton option.
PDF errors
You can experience PDF and latex related errors, caused very likely by missing or not complete latex instalation. Ycan use --no-manual option to skip PDF tests.
R --no-site-file CMD check --no-manual --as-cran /tmp/pkgtest
The answer above only works for Linux. On Windows I had to use a different method. When I tried to build and check my new package in R 3.2.0 on Windows 7, I got the same error:
checking package dependencies ... NOTE
No repository set, so cyclic dependency check skipped
I tried creating a file .Rprofile in my new package's root directory, but that didn't work. Instead I had to go to:
C:\Program Files\R\R-3.2.0\etc
and edit the file:
Rprofile.site
In the Rprofile.site file I added the suggested line:
options(repos = c(CRAN="http://cran.r-project.org"))
After I edited the Rprofile.site file, the NOTE
"No repository set, so cyclic dependency check skipped" finally disappeared.

How to identify LaTeX errors in .Rd R help files? [duplicate]

When building a package, I received the following warning:
* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.
I have no idea how to even begin diagnosing this. Is there a tool that tells me what .Rd file the problem is in?
I get no warnings about any of my Rd files in the checking documentation step....
Try R CMD Rd2pdf mypackage to create the manual, and possibly also set the --no-clean option to keep the temporary files. This should allow you to debug the LaTeX code triggering the error.
Though #Dirk's answer also helped me to fix the problem I would like to add a bit which might especially help recent updaters. That is, people who haven't encountered other LaTeX / R troubles after the update to 3.1.3 yet. The problem is little bit more general than just building. For me, on OS X the problem was that R CMD Rd2pdf as well as the R CMD CHECK expected texi2dvi to be in /usr/local/bin while it was in /usr/bin.
A symlink helped to fix the problem. On terminal type:
# to check whether the same issue exists for you
which texi2dvi
# if so
cd /usr/local/bin
ln -s /usr/bin/texi2dvi
Of course if the first line returns something else, you need to adapt the symlink here.
Concluding from the comments and from my own experience the problem often seems to be that some TeX fonts are missing, most often
inconsolata.sty and
upquote.sty
First you have to find the right directory where TeX fonts are stored - in my case this is:
C:\Program Files\R\R-3.3.0\share\texmf\tex\latex
Then you can download them here:
https://www.ctan.org/tex-archive/fonts/inconsolata/?lang=en
https://www.ctan.org/tex-archive/macros/latex/contrib/upquote?lang=en
Just copy them to the respective folder and in many cases the problem will be solved (in my case too). This should work for all operating systems.
...and another reason is that you haven't installed MikTex yet.
Download MikTex from here and follow the dialog prompts to install. I found the defaults to be reasonable and worked well for me.
Try to build your R package again. It should be OK now.
In my case, I had no error when running devtools::check() nor devtools::document() but when running R CMD check mypackage_version.tar.gz I got an error:
* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
* checking PDF version of manual without hyperrefs or index ... ERROR
In this question in RStudio Community they point to a problem with LATEX installation.
I have the LATEX installation suggested in R markdown cookbook: TinyTex.
I fixed the issue by running in the R console
tinytex::latexmk(file = "../mypackage.Rcheck/mypackage-manual.tex")
This command automatically updated my LATEX installation so the output file mypackage-manual.pdf was created. After this, I did not get any other error related to PDF when running R CMD check:
* checking PDF version of manual ... OK
* DONE
If you are on Ubuntu just install Tex Live by this command:
apt-get install texlive and restart Rstudo if you use it.
First, #dirk-eddelbuettel's approach in the current question identified the missing tex package (which was "makeindex" in my case).
system("R CMD Rd2pdf --no-preview --output=./documentation-peek.pdf ." )
# ... <omitted pages of output> ...
# Warning in sys2(makeindex, shQuote(idxfile)) : '"makeindex"' not found
# Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
# unable to run 'makeindex' on 'Rd2.idx'
# Error in running tools::texi2pdf()
Then #pedro-lima's answer in https://stackoverflow.com/a/69968791/1082435 worked for my specific case.
tinytex::tlmgr_install("makeindex")
Oftentimes this error occur because of Unicode characters in the package. In this cases, the error message might look like this.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
! Package inputenc Error: Unicode character (U+009D)
(inputenc) not set up for use with LaTeX.
You can find any Unicode characters in your package using tools::showNonASCIIfile(). Here's a simple way to check for these characters in your functions and documentation:
# functions
functions <- list.files(path = './R', all.files = T, recursive = T, full.names = T)
lapply(X=functions, FUN = tools::showNonASCIIfile)
# documentation
docs <- list.files(path = './man', all.files = T, recursive = T, full.names = T)
lapply(X=docs, FUN = tools::showNonASCIIfile)

NOTE in R CRAN Check: No repository set, so cyclic dependency check skipped

As of R 3.1.0 I get the following R check:
* checking package dependencies ... NOTE
No repository set, so cyclic dependency check skipped
I tried this advice: https://twitter.com/phylorich/status/431911660698083328
No go. I put the line options(repos="http://cran.rstudio.com/") in a .Rprofile in the package root directory. Still get the Note.
Also section 1.3.1 of Writing R Extensions states:
Some Windows users may need to set environment variable R_WIN_NO_JUNCTIONS
to a non-empty value. The test of cyclic declarations33in DESCRIPTION
files needs repositories (including CRAN) set: do this in ~/.Rprofile.
Is this possibly a result of the set environment variable R_WIN_NO_JUNCTIONS? If so how can I go about doing this? Any other possible causes of the note or suggested fixes?
From Writing R Extensions
The test of cyclic declarations in DESCRIPTION files needs repositories (including CRAN) set: do this in ~/.Rprofile, by e.g
options(repos = c(CRAN="http://cran.r-project.org"))
Recommended
User should double check if his .Rprofile is in his home and that it contains the mentioned option.
# in R session (any platform)
# where is my profile?
file.path(Sys.glob("~"),".Rprofile")
# is it there?
file.exists(file.path(Sys.glob("~"),".Rprofile"))
Or from R session using extra package:
library(pathological)
r_profile()
User should double check if the option entry is not nested in the IF condition, like in the following code:
# this will not help for R CMD check --as-cran
if(interactive()) {
options(repos = c(CRAN="http://cran.r-project.org"))
}
Dry run for any platform
Here is R script preparing easy temporary case of R package for testing, helping to faster find what is going wrong in your local usage.
This aproach helped myself to locate what was wrong in my .Rprofile file and generally can help to set up working initial state.
In best case, the check run should show only 1 NOTE about new submission.
first copy/paste the code and source it in your R session (--vanilla
preferably)
then run the command printed by the script to check test case --as-cran.
Example
# for example
R --vanilla -f makePackage.R
# here the resulting package path is as below
R --no-site-file CMD check --as-cran /tmp/pkgtest
# now see the check log
If your .Rprofile does not exist it will be created and one new line placed at the end of file in any case.
The makePackage.R script
# makePackage.R
# makes simple package for playing with check --as-cran
# copy this content to file makePackage.R
# then source it into your R --vanilla session
name <- "pkgtest"
#
# prepare and adjust package template
#
tempbase <- dirname(tempdir())
e <- new.env()
path <- dirname(tempdir())
# make simple package in path
e$fu <- function(){"Hello"}
package.skeleton(name=name,force=T,path=path,environment=e)
nil <- file.remove(
file.path(path,name,'Read-and-delete-me'),
file.path(path,name,'man',paste0(name,'-package.Rd'))
)
# adjust DESCRIPTION
D <- readLines(file.path(path,name,"DESCRIPTION"))
D[grepl("^Title: ",D)] <- "Title: Testing Skeleton"
D[grepl("^Author: ",D)] <- "Author: John Doe"
D[grepl("^Description: ",D)] <- "Description: Checking --as-cran check."
D[grepl("^Maintainer: ",D)] <- "Maintainer: John Doe <jdoe#doe.net>"
D[grepl("^License: ",D)] <- "License: GPL (>= 2)"
write(D,file.path(path,name,"DESCRIPTION"))
# make fu.Rd
write(
"\\name{fu}\\alias{fu}\\title{Prints}\\description{Prints}
\\usage{fu()}\\examples{fu()}",
file.path(path,name,'man','fu.Rd'))
#
# ensure that .Rprofile contains repos option
# add fresh new line et the end of .Rprofile
#
userRp <- file.path(Sys.glob("~"),".Rprofile")
write("options(repos = c(CRAN='http://cran.r-project.org'))",file=userRp, append=TRUE)
#
# print final message
#
msg <- sprintf("
Your test package was created in %s,
under name %s,
your user .Rprofile in %s was modified (option repos),
now check this test package from command line by command:
R --no-site-file CMD check --as-cran %s
", path, name, userRp, file.path(path,name)
)
# now is time to check the skeleton
message(msg)
Checking the package
# replace package-path by the path adviced by the sourcing the script above
R --no-site-file CMD check --as-cran package-path
There is user profile and site profile, in the approach above you bypasses site profile (in second step) by using --no-site-file option for package skeleton option.
PDF errors
You can experience PDF and latex related errors, caused very likely by missing or not complete latex instalation. Ycan use --no-manual option to skip PDF tests.
R --no-site-file CMD check --no-manual --as-cran /tmp/pkgtest
The answer above only works for Linux. On Windows I had to use a different method. When I tried to build and check my new package in R 3.2.0 on Windows 7, I got the same error:
checking package dependencies ... NOTE
No repository set, so cyclic dependency check skipped
I tried creating a file .Rprofile in my new package's root directory, but that didn't work. Instead I had to go to:
C:\Program Files\R\R-3.2.0\etc
and edit the file:
Rprofile.site
In the Rprofile.site file I added the suggested line:
options(repos = c(CRAN="http://cran.r-project.org"))
After I edited the Rprofile.site file, the NOTE
"No repository set, so cyclic dependency check skipped" finally disappeared.

Resources