checkCompilerOptions Error while installing package (littler/Docker) - r

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.

Related

R package installation error: "cannot remove earlier installation"

I'm currently making a R package (tessellation) which includes some C code. When I do some modifications and click "Install and restart" in RStudio, I get this error:
==> Rcmd.exe INSTALL --no-multiarch --with-keep.source tessellation
* installing to library 'C:/PortableApps/R/R-4.1.2/App/R-Portable/library'
* installing *source* package 'tessellation' ...
ERROR: cannot remove earlier installation, is it in use?
When I do "Restart R session" before "Install and restart", sometimes this works, sometimes not. So I have to close the project and reopen it, and this is annoying. Do you know what could I do to work more conveniently?
You need to be sure that the process is not being used (or loaded into R's search path) for the package. I suggest stopping all R sessions, deleting the installed package folder manually, start an R vanilla session, check the attached packages/search path, and finally attempt re-installation/building the package:
# from terminal
R --vanilla
# check search path
ls()
search()
# attempt installing package
devtools::install() # or devtools::build()

R can't find packages installed by travis

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...

Building R package: "No man pages found in package"

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.

R CMD INSTALL error: Unexpected Symbol in test_load_package() function

Issue:
I'm just trying to build a few packages from source and am running into an error
Error: unexpected symbol in "tools:::.test_load_package('rbenchmark',
'\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell"
Full output below:
C:\ROracle>R CMD INSTALL --build --merge-multiarch rbenchmark_1.0.0.tar.gz
install for i386
* installing to library '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15'
* installing *source* package 'rbenchmark' ...
** package 'rbenchmark' successfully unpacked and MD5 sums checked
** R
** demo
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: unexpected symbol in "tools:::.test_load_package('rbenchmark', '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell"
Execution halted
ERROR: loading failed
* removing '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15/rbenchmark'
Question:
Is the error coming from the apostrophe (') from O'Dell in the path?
If yes, is it a bug since it isn't escaping the apostrophe in the directory?
Is it trying to install into my default library?
If yes, can I change the library as a parameter in R CMD INSTALL?
If I can't specify the library, should I remove that library altogether?
Extra Info:
Here's the output of .libPaths()
[1] "\\\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15"
[2] "C:/Program Files/R/R-2.15.2/library"
[3] "C:/Program Files/RStudio/R/library"
As I see it, the error comes from the apostrophe - R can't know that this doesn't end the path, but is part of it. Try it without it and it should work I guess. One solution might be also to use this kind of quotation instead " ", maybe this works out as well, because then the apostrophe doesn't end it any more...
EDIT: In order to install a package foo via command line to an specific library folder via command line you can use
R CMD build foo
R CMD INSTALL -l /home/daniel/myPkg/ foo_1.0.tar.gz
This means in your case this should work:
R CMD INSTALL --build --merge-multiarch -l C:/Program Files/RStudio/R/library rbenchmark_1.0.0.tar.gz

R installation for RHive and/or RStudio("--enable-R-shlib")

I suspect I am having a problem with my R installation, something that has to do with "--enable-R-shlib".
Can someone explain if this is something that I can fix using apt-get?
More specifically:
I am having trouble getting installing the RHive package.
I Installed R from scratch, following the instructions in (for example):
http://cran.ru.ac.za/bin/linux/ubuntu/
basically, just doing:
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
Next I opened R and installed rJava:
install.packages("rJava")
which worked fine.
Next I tried installing RHive:
install.packages("RHive")
at which point the installation fails with the following message:
* installing *source* package ‘Rserve’ ...
** package ‘Rserve’ successfully unpacked and MD5 sums checked
checking whether to compile the server... yes
configure: error: R was configured without --enable-R-shlib or --enable-R-static-lib
*** Rserve requires R (shared or static) library. ***
*** Please install R library or compile R with either --enable-R-shlib ***
*** or --enable-R-static-lib support ***
What Should I Do?
Also, I installed RStudio and this fails at startup with a related message:
"R shared library (/usr/local/lib64/R/lib/libR.so) not found. If this is a custom build of R, was it built with the --enable-R-shlib option"
All of which leads me to believe it is all related to the same problem. Weird thing is, I followed the same procedure on a different machine, and all seems to work fine...
I had the same problem.
In my case I changed R_HOME like this Sys.setenv(R_HOME="/usr/lib/R")
R, as well as r-cran-rjava and r-cran-rserve are available for Debian and Ubuntu as part of the basic distribution.
Can you not use those packages? They certainly work for me and many, many other people at least as far as RStudio is concerned -- I have not tried RHive myself.

Resources