I am trying to develop a R package with RStudio. Lately, I have had no success.
devtools::build(), devtools::reload() and devtools::check() give:
Updating CF documentation
Loading CF
Error in aes(x = gdpPercap, y = lifeExp, size = pop, color = continent, (from mapping.R#1) :
could not find function "aes" or the data.
devtools::check() gives other information, which I list below.
Clean and Rebuild gives:
1] "/Users/PJO/Desktop/CF_0.1.0.tar.gz"
==> R CMD INSTALL --preclean --no-multiarch --with-keep.source CF.2.24
installing to library ‘/Users/PJO/Library/R/3.4/library’
installing source package ‘CF’ ...
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in aes(x = gdpPercap, y = lifeExp, size = pop, color = continent, :
could not find function "aes"
Error : unable to load R code in package ‘CF’
ERROR: lazy loading failed for package ‘CF’
* removing ‘/Users/PJO/Library/R/3.4/library/CF’
* restoring previous ‘/Users/PJO/Library/R/3.4/library/CF’
Exited with status 1.
My search has shown that other developers have experienced similar problems. I believe that it connected to (a) devtools and some (b) lingering code. I cannot prove it.
The following efforts have not worked: (1) restarting R, (2) removing invisible files, .R*, (3) rebooting RStudio, (4) debugging all functions with RStudio debug() before committing them to the R package, ... . The error suggests that I have not loaded all the data or required libraries. The above error directs attention to the R library "gapminder." It calls "aes" therefore, it should load. With or without loading "gapminder," I obtain the same error. So, I suspect some hidden files are lurking in the background.
To compare, I tested an old version of my CF package. It works:
==> R CMD INSTALL --preclean --no-multiarch --with-keep.source CF
installing to library ‘/Users/PJO/Library/R/3.4/library’
installing source package ‘CF’ ...
** R
** data
* moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
* installing help indices
** building package indices
** testing if installed package can be loaded
DONE (CF)
Other attempts include using browser() and traceback() from Rstudio debug() fail. They fail because of the Clean and Rebuild fails before debug() is called.
Some devtools::check() failures for my latest CF package:
The Title field should be in title case, current version then in title case:
‘Stochastic traffic performance and car-following modeling tools’
‘Stochastic Traffic Performance and Car-Following Modeling Tools’
── Install failure ─────────────────────────────────────────────────────────────────────────
checking for empty or unneeded directories
Removed empty directory ‘CF/inst/extdata’
Removed empty directory ‘CF/inst’
looking to see if a ‘data/datalist’ file should be added
building ‘CF_0.1.0.tar.gz’
Some devtools::check() failures for my older CF package:
The Title field should be in title case, current version then in title case:
‘A package for performing analyses with stochastic traffic performance and car-following models’
‘A Package for Performing Analyses with Stochastic Traffic Performance and Car-Following Models’
plotfollow2: no visible binding for global variable ‘leff’
Undefined global functions or variables:
leff
These errors do not cause Clean and Rebuild error.
As you can see, I have run out of things to try. For another, I am experienced enough to know if I am overlooking something. For example, I am taking the Title problem seriously. To be honest, the suggested corrective action does not make sense to me.
Help would be greatly appreciated.
Paul
Related
I am trying to reinstall a package that I was previously able to install and use. I was building a package of my own after my computer unexpectedly restarted and then I started to have problems loading the rpgraph package. So I decided to uninstall it and to reinstall it. When I did so I got the following error:
library(devtools)
library(rJava)
install_github("Albluca/rpgraph")
Downloading GitHub repo Albluca/rpgraph#master
from URL https://api.github.com/repos/Albluca/rpgraph/zipball/master
Installing rpgraph
Running command /usr/lib/R/bin/R
Arguments:
CMD
INSTALL
/tmp/Rtmp5OrtLL/devtools505a703b3ccd/Albluca-rpgraph-de04f96
--library=/home/gonzalo/R/x86_64-pc-linux-gnu-library/3.4
--install-tests
installing source package ‘rpgraph’ ...
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Segmentation fault (core dumped)
ERROR: loading failed
removing ‘/home/gonzalo/R/x86_64-pc-linux-gnu-library/3.4/rpgraph’
Installation failed: run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout), stderr_line_callback = real_callback(stderr), stdout_callback = real_block_callback, stderr_callback = real_block_callback, echo_cmd = echo, echo = show, spinner = spinner, error_on_status = fail_on_status, timeout = timeout) : System command error`
I tried reinstalling JAva and cran from zero but somehow there is something that remains in my system that avoids the package to be installed. Also, since the error is not very informative, I have no idea on how to narrow where the problem is.
Thanks for any help you can provide.
I experienced the same problem while installing the libraries vanneuler and wordnet and solved the issue using the solution proposed by Kenneth. In my case the option -Xss2560k was enough to solve:
export _JAVA_OPTIONS="-Xss2560k"
In addition: instead of running the export command from the terminal the java option can be set directly from the R session with the following command:
options(java.parameters = "-Xss2560k")
This seems to be a bug in recent kernel versions, the same problem happens with other R libraries that involve Java, and also other software.
See https://lists.ubuntu.com/archives/ubuntu-devel-discuss/2017-June/017507.html and https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1698919.
This workaround does the trick for me:
export _JAVA_OPTIONS="-Xss2560k -Xmx2g"
I am unable to generate .Rd documentation files for my package using RStudio and Roxygen2. First, let me mention that I have gone through similar problems posted here and have already done the following:
Roxygen2 blocks initiated at the beginning of file with a #'
Configured Build Tools>Checked generate documentation with Roxygen> Configure > Checked all fields under 'Use roxygen to generate' and 'Automatically roxygenize when running'
Made sure there were no .Rd files in the 'man' folder
And even after that, when I perform a 'Build and Reload' on RStudio I get the following output (please note the line that reads: No man pages found in package MYPACKAGE:
=
=> devtools::document(roclets=c('rd', 'collate', 'namespace', 'vignette'))
>
Updating MYPACKAGE documentation
Loading MYPACKAGE
Documentation completed
==> Rcmd.exe INSTALL --no-multiarch --with-keep.source MYPACKAGE
installing to library C:/Users/user/Documents/R/win-library/3.3
installing source package 'MYPACKAGE' ...
** R
** data
* moving datasets to lazyload DB
** preparing package for lazy loading
No man pages found in package 'MYPACKAGE'
** help
* installing help indices
** building package indices
** testing if installed package can be loaded
DONE (MYPACKAGE)
Edit:
Upon further investigation, it appears that this was caused by the fact that I have sub-directories within my R directory, which is not supported by default. A possible solution was located here which, however, I haven't yet tried out. I will report back with the outcome as soon as I am able to perform the tests.
I had the same error. roxygen2 was creating correctly the md files in the /man directory but they were not found at compilation time. I had the following error.
No man pages found in package
After a bit of time I found that in one of the R file I had a source statement
source("C:/Users/vaulot/Google Drive/Scripts/R library/dv_function_pr2.R")
My guess is that there was some code in the source file interfering with roxygen2.
On its last line, this Docker file calls littler::install.r to install Rcpp RcppEigen and matrixStats.
The whole code was working like a charm a couple of months back. Now, it bombs at that last step. More precisely, Rcpp and RcppEigen still install perfectly, but when it comes to installing matrixStats, I get:
installing to /usr/local/lib/R/site-library/matrixStats/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object 'checkCompilerOptions' not found
Calls: ::: -> get
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/matrixStats’
The downloaded source packages are in
‘/tmp/downloaded_packages’
Warning message:
In install.packages(f, lib, if (isMatchingFile(f)) NULL else repos) :
installation of package ‘matrixStats’ had non-zero exit status
It's an error I never had before and have trouble locating where it is even coming from. What could be causing this problem? Any info would already help a lot.
However, with R-devel using rocker/r-devel,
docker run --rm -ti rocker/r-devel /bin/bash
RD
install.packages("matrixStats")
Gives the same error. I'm guessing this is another R-devel change which takes away things we took for granted before, in this case something to do with compiler package. I don't however have a solution, yet. Just (re-)installing or attaching compiler doesn't help.
Update
Using R CMD INSTALL --no-byte-compile allows backports to install for me, which was the package I was having trouble with.
From the top of my head I'd blame a change in matrixStats [ but see below and it appears blameless ] -- I am somewhat familiar with all the other moving parts and not aware of changes or bugs.
One thing that is fishy though is the trailing line break:
RUN install.r Rcpp RcppEigen matrixStats \
You may try without it.
Edit: And for what it is worth I just fired up our standard base layer Docker image r-base via
docker run --rm -ti r-base /bin/bash
and invoked
install.r Rcpp RcppEigen matrixStats
which executed just fine.
So if sonething is wrong with that other Docker container you may have to take it up with its author and work through his changes relative to our Dockerfile he seems to have used as a base.
We're trying to add some unit tests to the caret package that get run by travis, but not on CRAN. This saves build time on CRAN and reduces the number of dependencies they have to install to check our package, while letting us run a more complete test suite on travis.
I thought I could simply install the requirements for the test using the r_packages: line in my travis.yml file:
r_packages:
- ROSE
- DMwR
However, my NOT_CRAN=TRUE builds are still failing. (NOT_CRAN=FALSE runs fine as the problematic tests are skipped)
This is really strange, as when I look at the build logs, I see travis successfully installing all the packages I need:
* installing *source* package ‘ROSE’ ...
** package ‘ROSE’ successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (ROSE)
But when my tests run that depend on those packages, R can't find them:
> library(testthat)
> library(caret)
Loading required package: lattice
Loading required package: ggplot2
>
> test_check("caret")
[1] "Reduced dimension to 3 by default. "
1 package is needed for this model and is not installed. (ROSE). Would you like to try to install it now?1. Error: check appropriate sampling calls by name -----------------------------
1: withCallingHandlers(eval(code, new_test_environment), error = capture_calls, message = function(c) invokeRestart("muffleMessage"),
warning = function(c) invokeRestart("muffleWarning"))
2: eval(code, new_test_environment)
3: eval(expr, envir, enclos)
4: caret:::parse_sampling(i) at test_sampling_options.R:14
5: checkInstall(pkgs)
6: stop()
testthat results ================================================================
OK: 62 SKIPPED: 0 FAILED: 1
1. Error: check appropriate sampling calls by name
Error: testthat unit tests failed
Execution halted
(I think) the relevant line of code is here in caret's source code:
good <- rep(TRUE, length(pkg))
for(i in seq(along = pkg)){
tested <- try(find.package(pkg[i]), silent = TRUE)
if(class(tested)[1] == "try-error") good[i] <- FALSE
}
Why can't the find.package function find packages installed by travis? Do they go in a special, separate library somewhere?
Also, as an aside, how do I make my travis builds for r less verbose? By default they seem to print way too much information (e.g. it echoes all code run by the tests and manual, even code that doesn't error).
When testing your package on Travis, R CMD check appears to be looking for installed packages in the wrong place(s).
I created a small test package to figure this out:
When testing the package on Travis using R CMD check, .libPaths() contains:
c("/tmp/RtmpnQE1WM/RLIBS_29bd3940b7fa",
"/usr/lib/R/library")
When testing the package on Travis using devtools::test(), .libPaths() contains:
c("/usr/local/lib/R/site-library",
"/usr/lib/R/site-library",
"/usr/lib/R/library")
By default, R packages on Travis are installed into /usr/local/lib/R/site-library (i.e. the first entry of .libPaths()). Clearly, R CMD check is looking in the wrong place(s).
In principle, we could use the --library argument for R CMD check to point to the right place, however when you use --as-cran then --library defaults to /usr/lib/R/library.
The easiest solution is probably to install all packages (in particular the "additional" packages ROSE and DMwR) into /usr/lib/R/library. There are many ways to do that. One solution is to add
sudo mkdir -p /usr/lib/R/library
echo 'R_LIBS=/usr/lib/R/library:/usr/lib/R/site-library/' > ~/.Renviron
sudo chmod 2777 /usr/lib/R/library
to the before_install section of your .travis.yml file.
You could clone the r-travis repo and just source from your copy. That would allow you to make it less verbose.
As to "packages not found": dunno. But the Travis instance is a vanilla Ubuntu installation so you can control things by echo'ing into a suitable ~/.Rprofile etc pp. I have found the old r-travis setup to be more convenient for me and recently blogged about one way to dramatically cut test times down by relying more on pre-built r-cran-* .deb packages.
Michael has well over 1000 in his repo, and you could build your own too via a PPA. Time permitting I may write another blog post detailing that...
My previously-functioning R package lllcrc recently broke, so I tweaked it, and now I'm having trouble building it again because it acts like it can't see my documentation files:
R CMD INSTALL lllcrc
* installing to library ‘/home/[...]/3.1’
* installing *source* package ‘lllcrc’ ...
** R
** preparing package for lazy loading
** help
No man pages found in package ‘lllcrc’
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (lllcrc)
This is totally weird because I definitely have a complete set of .Rd files in the man folder; in fact, I generated all of these using roxygen2, and all of this worked previously. The R CMD INSTALL even works enough so that the package actually installs and all of its examples run. But documentation is missing. Running ?foo just gives a "no documentation" message.
Another thing: R CMD Rd2pdf lllcrc generates the .pdf documentation as I would expect.
Any ideas?
I just had the same error message ... if you are using roxygen and RStudio then your problem might be the same. The reason became apparent when looking at "Configure build tools" in the "Build" drop-down menu: you need to tick the checkbox "Generate documentation with Roxygen". After that, everything worked.