I create a new package with RStudio. In "Configure Build Tools", I check "Generate documentation with Roxygen".
The first time I click on "Document" in the "Build" pane, everything works fine:
==> roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))
First time using roxygen2. Upgrading automatically...
Writing hello.Rd
Writing NAMESPACE
Documentation completed
I get this NAMESPACE:
# Generated by roxygen2: do not edit by hand
export(hello)
and this file hello.Rd
:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hello.R
\name{hello}
\alias{hello}
\title{Hello}
\usage{
hello(x)
}
\arguments{
\item{x}{string}
}
\value{
a string
}
But now, I modify the file hello.R
, and then I get two problems.
Firstly, this window appears:
If I click on "Yes", nothing happens.
Secondly, it seems that roxygen2
cannot overwrite hello.Rd
, because I get this text in the "Build" pane:
==> roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))
Error: The specified file is not readable: U:\Data\Rtests\testPackage\man/hello.Rd
Execution halted
Exited with status 1.
The only way I found to update the documentation is to run:
roxygen2::roxygenize(clean=TRUE)
This command firstly cleans everything, the NAMESPACE and the Rd
files, and then generates the NAMESPACE and the Rd
files.
I don't know whether this is an issue with the path of Rtools
. I tried to set the path by doing:
Sys.setenv(PATH="%PATH%;C:/Program Files/Rtools/gcc-4.6.3/bin;C:/Program Files/Rtools/gcc-4.6.3/bin64;C:/Program Files/Rtools/gcc-4.6.3/i686-w64-mingw32/bin;C:/Program Files/Rtools/bin")
But that does not solve the issue.
I'm using:
roxygen2 5.0.1
RStudio 0.99.892
Windows 7
R version 3.3.1
The roxygen2
package depends on the digest
package. The error (The specified file is not readable) is generated by the digest
function of the digest
package, at the moment when this function calls the file.access
function: https://github.com/eddelbuettel/digest/blob/master/R/digest.R#L102.
I get:
> file.access("U:/Data", 4)
U:/Data
-1
That means that U:/Data
has not the read permission. But this is not true: it has the read permission. The problem is that my U:
drive is a "network drive", and there are some issues with the file.access
function for network drives, as we can see here for example: https://github.com/eddelbuettel/digest/issues/13.
The problem would be solved if R.utils::fileAccess
would be used instead of file.access
in the digest::digest
function.
So, firstly take the code of the digest::digest
function and modify it as follows.
mydigest <- function (object, algo = c("md5", "sha1", "crc32", "sha256",
"sha512", "xxhash32", "xxhash64", "murmur32"), serialize = TRUE,
file = FALSE, length = Inf, skip = "auto", ascii = FALSE,
raw = FALSE, seed = 0, errormode = c("stop", "warn", "silent"))
{
file.access <- R.utils::fileAccess
.... the code of the digest function here ...
}
Then do:
library(digest)
R.utils::reassignInPackage("digest", "digest", mydigest)
And now the documentation can be updated by doing:
roxygen2::roxygenize()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With