R: Problems installing package (related to space in directory name?) - r

I'm trying to install the CausalImpact package and failing due to a dependency on bsts.
I've tried to install bsts without success, and looking at the results I see what I think is a failure on a dependency for Boom:
install.packages("bsts", lib="C:/R/win-library/3.3")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘bsts’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘bsts’
trying URL 'https://cran.rstudio.com/src/contrib/bsts_0.6.3.tar.gz'
Content type 'application/x-gzip' length 148815 bytes (145 KB)
downloaded 145 KB
* installing *source* package 'bsts' ...
** package 'bsts' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
c:/Rtools/mingw_32/bin/g++ -std=c++0x -I"C:/PROGRA~1/R/R-33~1.0/include" -DNDEBUG -I`C:/PROGRA~1/R/R-33~1.0/bin/Rscript -e "cat(system.file(package='Boom'))"`/include -DNO_BOOST_THREADS -DNO_BOOST_FILESYSTEM -DADD_ -DR_NO_REMAP -DRLANGUAGE -I"C:/Users/Firstname Lastname/Documents/R/win-library/3.3/Boom/include" -I"C:/Users/Firstname Lastname/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O2 -Wall -mtune=core2 -c aggregate_time_series.cc -o aggregate_time_series.o
g++.exe: error: Lastname/Documents/R/win-library/3.3/Boom/include: No such file or directory
What I assume is that g++ is getting upset because R has put the library in a subfolder of C:Users/Firstname Lastname, and it's not liking the space in my name.
I tried setting the R_LIBS_USER environment variable to C:/R/win-library/3.3 to eliminate this problem with a space in the path, but with no success - even after a full restart of the computer, the error repeats - it's still going to the C:/Users/Firstname Lastname/Documents/R/win-library/3.3 directory.
I'm using RStudio 0.99.896 with R 3.3.0 on Windows 10, if that makes any difference

As suggested in this related question if you don't necessarily need the latest version of bsts you can still install version 0.6.2 on Windows, and that will let you install CausalImpact:
install.packages("https://cran.r-project.org/bin/windows/contrib/3.2/bsts_0.6.2.zip",
repos = NULL, type = "local")
library(devtools)
devtools::install_github("google/CausalImpact")
works on Win 10, R 3.3.0

Related

Error message "version `CXXABI_1.3.8' not found" appears when running an INLA model in R [duplicate]

I know this question has been asked many times, but my case is very special: I am using a Linux cluster where I do not have root but could only use commands like "module load gcc" "module load mkl" "module load R3.3/mkl" and so on to load libraries.
Recently I tried installing mxnet on my account on that cluster, after that everything seems to work, but then I switched from R3.2 to R3.2 by using "module load R3.3/mkl" instead of "module load R3.2/mkl", but now when I try to load R packages like stringi, it said
library(stringi),
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/stringi/libs/x
86_64/stringi.so':
/usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/hpc/pr74ze/ru37wof2/R/x86
_64-pc-linux-gnu-library/3.3/stringi/libs/x86_64/stringi.so)
Error: package or namespace load failed for ‘stringi’
I remember that I have tried to load gsl before
module list
Currently Loaded Modulefiles:
1) admin/1.0 3) intel/16.0 5) mpi.intel/5.1 7) R/3.3mkl 9) git/latest 11) gsl/1.16
2) tempdir/1.0 4) mkl/11.3 6) lrz/default 8) nano/2.2 10) gcc/4.9
if I run the following
echo $LD_LIBRARY_PATH
/usr/lib64:/lrz/mnt/sys.x86_64/compilers/java/jdk1.7.0_51/jre/lib/amd64/server:/usr/lib64:/lrz/mnt/sys.x86
_64/compilers/java/jdk1.7.0_51/jre/lib/amd64/server:/lrz/sys/libraries/gsl/1.16/lib:/lrz/sys/compilers/gcc
/4.9.3/lib64:/lrz/sys/compilers/gcc/4.9.3/lib:/lrz/sys/applications/R/3.3.1_MKL/lib64/R/lib/x86_64:/lrz/sy
s/intel/impi/5.1.3.181/lib64:/lrz/sys/intel/studio2016_u4/compilers_and_libraries_2016.4.258/linux/mkl/lib
/intel64:/lrz/sys/intel/studio2016_u4/debugger_2016/libipt/intel64/lib:/lrz/sys/intel/studio2016_u4/compil
ers_and_libraries_2016.4.258/linux/compiler/lib/intel64
If I try to install the RcppZiggurat
* installing *source* package ‘RcppZiggurat’ ...
** package ‘RcppZiggurat’ successfully unpacked and MD5 sums checked
** libs
*** arch - x86_64
icpc -I/lrz/sys/applications/R/3.3.1_MKL/lib64/R/include -I/lrz/sys/applications/R/3.3.1_MKL/lib64/R/include/x86_64 -DNDEBUG -I. -I../inst/include -I/usr/local/include -I"/home/hpc/pr74ze/ru37wof2/R/x86_64-pc-lin
ux-gnu-library/3.3/Rcpp/include" -I"/home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/RcppGSL/include" -fpic -O3 -c RcppExports.cpp -o RcppExports.o
In file included from /home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/RcppGSL/include/RcppGSL.h(25),
from RcppExports.cpp(4):
/home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/RcppGSL/include/RcppGSLForward.h(26): catastrophic error: cannot open source file "gsl/gsl_vector.h"
#include <gsl/gsl_vector.h>
^
compilation aborted for RcppExports.cpp (code 4)
But how should I proceed to find out where the problem is?
Note the 3.3 hiding inside of /home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/stringi/libs/x 86_64/stringi.so -- you probably built that under 3.2 so it sits below /home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.2.
You can overcome this by setting your own .libPaths(), either directly or via environment variables -- you may want something like ~/R/library. See help(Startup) for details.

Centos 8, R, EPEL 8, dplyr --> `GLIBCXX_3.4.26' not found

I'm on Centos 8, dictated by corporate IT. I have EPEL 8 added to the repositories, and I've installed R. I'm trying to install the popular CRAN package, dplyr, so I can use its functions in R. I've used it a pile of times on different environments, including Centos 7.
> install.packages("dplyr")
Installing package into ?/home/user/R/x86_64-redhat-linux-gnu-library/3.6?
(as ?lib? is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/dplyr_0.8.5.tar.gz'
Then it goes and downloads the package and goes through a lot of compile steps. Skipping to the last part of the compiling,
g++ -m64 -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o dplyr.so RcppExports.o address.o api.o arrange.o between.o bind.o distinct.o encoding.o filter.o group_indices.o hybrid.o init.o join.o join_exports.o mutate.o rlang-export.o rlang.o select.o set.o summarise.o test.o utils-bindings.o utils.o window.o -L/usr/lib64/R/lib -lR
installing to /home/user/R/x86_64-redhat-linux-gnu-library/3.6/00LOCK-dplyr/00new/dplyr/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/user/R/x86_64-redhat-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so':
/lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/user/R/x86_64-redhat-linux-gnu-library/3.6/Rcpp/libs/Rcpp.so)
So, I'm clearly unable to find GLIBCXX_3.4.26. I'm unclear on a few things, including which of my packages requires it (does dplyr require it, or is it innocently calling a library which requires it). I know that I'm not gong to get GLIBCXX_3.4.26 in Centos 8. But now I need to understand if I need to find an installer for R that needs an earlier version (which I might find in EPEL 7?) or if I need to find an earlier version of dplyr (which I might find in archives of CRAN?)
My R version that yum list installed reports is 3.6.3-1.el8. My stdc++ is 8.3.1-4.5.el8.

Installing Rcpp in rocker/r-devel-ubsan-clang

I'm trying to replicate CRAN sanitizer failures for my R package that depends on Rcpp on the rocker/r-devel-ubsan-clang docker image.
When I try to install Rcpp I get an error about no type named 'R_ContinueUnwind'. Is this something I'm doing wrong, or is it an incompatibility with Rcpp and Rdevel?
If the latter, is there a way to get a similar docker image that uses address sanitizers for a non-development version of R?
Here's the command I've been trying to run and output:
docker run --cap-add SYS_PTRACE --rm -it rocker/r-devel-ubsan-clang /bin/bash
root#e9f11aceb087:/# Rscriptdevel -e "install.packages('Rcpp')"
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/Rcpp_0.12.18.tar.gz'
Content type 'application/x-gzip' length 3809164 bytes (3.6 MB)
==================================================
downloaded 3.6 MB
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
clang++-4.0 -stdlib=libc++ -fsanitize=address,undefined -fno-sanitize=float-divide-by-zero -fno-omit-frame-pointer -fsanitize-address-use-after-scope -I/usr/local/lib/R/include -DNDEBUG -I../inst/include/ -I/usr/local/include -fpic -g -O3 -Wall -pedantic -mtune=native -c Date.cpp -o Date.o
In file included from Date.cpp:31:
In file included from ../inst/include/Rcpp.h:27:
In file included from ../inst/include/RcppCommon.h:128:
../inst/include/Rcpp/exceptions.h:150:7: error: no type named 'R_ContinueUnwind' in the global namespace
::R_ContinueUnwind(token);
~~^
1 error generated.
/usr/local/lib/R/etc/Makeconf:166: recipe for target 'Date.o' failed
make: *** [Date.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/usr/local/lib/R/site-library/Rcpp’
The downloaded source packages are in
‘/tmp/RtmpqVuvlD/downloaded_packages’
Warning message:
In install.packages("Rcpp") :
installation of package ‘Rcpp’ had non-zero exit status
Edit
Here's the result of docker image list and from within the container Rdevel --version
docker image list rocker/r-devel-ubsan-clang
REPOSITORY TAG IMAGE ID CREATED SIZE
rocker/r-devel-ubsan-clang latest c769161f77fb 10 months ago 4.47GB
And Rdevel --version
Rdevel --version
R Under development (unstable) (2017-09-16 r73288) -- "Unsuffered Consequences"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
http://www.gnu.org/licenses/.
I got that image by using docker pull, I'm now trying to build it from scratch, following the lead that the image is 10 months old.
Maintainer of that repo here. We could probably discuss that over at the repo in an issue ticket too. I have not tried compiling R-devel with clang myself in some time (as I build r-devel at home via gcc), so not sure why the symbol is missing.
The whole concept was picked up by Winston who created a whole battery of debug Docker containers in this repo.
Otherwise, the (excellent) R hub builder also has sanitizer builds. One remaining problem is that CRAN is not too forthcoming with changes to their setup (besides publishing their short descriptions) so it is never clear if the setup is in fact identical to theirs.
Edit: Actually grep'ing for your symbol shows that it is contingent on R version 3.5.0 or later:
#if (defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0))
::R_ContinueUnwind(token);
#endif
Can you double check your container setup if that is given? We may have a mismatch here then between R version and R-devel version -- should be easy to fix.

How use the option -std=c99 for installing R packages

I have problem in installing plyr R package, and got the following error:
Installing package into '/home/mousavian/R/x86_64-pc-linux-gnu-library/3.2'
(as 'lib' is unspecified)
* installing *source* package 'plyr' ...
** package 'plyr' successfully unpacked and MD5 sums checked
** libs
g++ -I/share/apps/R/lib64/R/include -DNDEBUG -I/usr/local/include -I"/home/mousavian/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include" -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o
gcc -I/share/apps/R/lib64/R/include -DNDEBUG -I/usr/local/include -I"/home/mousavian/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include" -fpic -g -O2 -c loop_apply.c -o loop_apply.o
loop_apply.c: In function 'loop_apply':
loop_apply.c:15:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
for(int i = 0; i < n1; i++) {
^
loop_apply.c:15:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
make: *** [loop_apply.o] Error 1
ERROR: compilation failed for package 'plyr'
* removing '/home/mousavian/R/x86_64-pc-linux-gnu-library/3.2/plyr'
Warning message:
In install.packages("R packages/plyr_1.8.3.tar.gz", repos = NULL) :
installation of package 'R packages/plyr_1.8.3.tar.gz' had non-zero exit status
How can I use -std=c99 option when try to install R packages from the source by install.packages command?
Thanks
Try C11 First
The compiler error tells you to choose either C99 or C11. So unless you're knowingly compiling legacy code, try C11 first. You can always then try the legacy C99 if that doesn't work.
Use withr::with_makevars
Editing individual package Makevars or coordinating global changes to your include/lib directories for every package that doesn't directly compile from source is not a happy strategy for the future. Don't do that! A great alternative to editing your R's make configuration is to use withr::with_makevars to manipulate the Makevars only for the installation command:
library(withr)
with_makevars(c(PKG_CFLAGS = "-std=c11"),
install.packages("plyr", repos = NULL, type = "source"),
assignment = "+=")
Plus, you likely already have withr installed since it's a devtools dependency.
If not already existing, create a directory in your $HOME (/home/mousavian/.R in your case). Inside, create a Makevars file (no extension). Edit this file with your favorite editor and write:
CC = gcc -std=c99
Then, save it and after starting R, simply run
install.packages("plyr", dependencies = TRUE)
It should compile with gcc -std=c99.
The default /etc/R/Makeconf includes CC = gcc -std=gnu99 (R 3.3.2 and probably most or all other recent versions, although I think the in-progress development version jumps up into the 21st century)
The accepted answer may well work, but is not the R default. Setting CC=gcc with no other options would drop this default, and this another reason for getting this error. Best to leave defaults alone unless you know what you're doing.
As an addendum, to possibly save someone a few minutes: I ran into a similar issue after an R update to 3.3.2 on an Rstudio server (that I have no control over), but with g++. Compiler options for g++ may be added to Makevars like this:
CXX1XSTD = -std=gnu++11
(the package I needed to compile required gnu++11)

How to install rgdal and rgeos package in R on university high performance computing system?

I have been installing R packages from tar.gz type files on Edinburgh university's compute and data facility which is a high performance computing cluster which is accessed via SSH. Once logged in, I can install the files as the example below:
install.packages("/exports/work/eng_AntonyHydroData/Pkges/DEoptim_2.2-3.tar.gz",rpeo=NULL,target="source")
There are approximately 40 packages and 38 of them install no problem, but two fail: RGEOS (rgeos_0.3-14.tar.gz) and RGDAL (rgdal_1.0-7.tar.gz).
The reason for failure is given below:
Installing package into '/exports/work/eng_AntonyHydroData/library'
(as 'lib' is unspecified)
inferring 'repos = NULL' from 'pkgs'
* installing *source* package 'rgdal' ...
** package 'rgdal' successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 1.0-5
checking for /usr/bin/svnversion... yes
configure: svn revision: 559
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package 'rgdal'
Note that RGEOS gives the same reason i.e. gdal-config is missing.
I have looked around the net and have found various answers to this problem that mainly suggests to install libgeos-dev or something similar using the command 'sudo' or 'apt-get' but neither of these commands are recognised by the computing cluster system.
Any help in getting RGEOS and RGDAL to work would be very much appreciated.
Antony
I managed to solve this by first installing the geos-3.5.0.tar.bz2 package and issuing the following linux commands:
tar xjvf geos-3.5.0.tar.bz2
cd geos-3.5.0
./configure --help
mkdir /exports/work/....
./configure --help,
./configure --prefix=eng_A... --enable-python
make
make check
make install
and similar for rgdal
I'm not sure how your HPC system is setup but as the previous comment implied, you need "geos" installed/loaded. The system I work on uses the "module" command to load programs, so I use "module available" to find where "geos" is on the system so you can load it.
Here's an example from another system: http://docs.hpc.shef.ac.uk/en/latest/iceberg/software/apps/r.html

Resources