cannot install R package: CMake errorr - r

I am trying to install factoextra, but I gets stuck during the CMake part, in particular with error like:
CMake Error: The source directory "/tmp/..." does not exist.
(same when I try to install its dependencies: nloptr, pbkrtest, lme4, car, rstatix, FactoMineR, ggpubr )
any idea?
thanks
ps:
R version 4.0.0
centos 7
last part of logs:
CMake Error: The source directory "/tmp/RtmpgJySdf/R.INSTALL20c31df42f6/nloptr/src/nlopt-build" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Unknown argument -j
Unknown argument 2
Usage: cmake --build <dir> [options] [-- [native-options]]
Options:
<dir> = Project binary directory to be built.
--target <tgt> = Build <tgt> instead of default targets.
--config <cfg> = For multi-configuration tools, choose <cfg>.
--clean-first = Build target 'clean' first, then build.
(To clean only, use --target 'clean'.)
--use-stderr = Don't merge stdout/stderr output and pass the
original stdout/stderr handles to the native
tool so it can use the capabilities of the
calling terminal (e.g. colored output).
-- = Pass remaining options to the native tool.
CMake Error: The source directory "/tmp/RtmpgJySdf/R.INSTALL20c31df42f6/nloptr/src/nlopt" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
cp: cannot stat 'nlopt/include/*': No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I"/opt/R/4.0.0/lib/R/include" -DNDEBUG -I../inst/include -I'/opt/R/4.0.0/lib/R/library/testthat/include' -I/usr/local/include -fpic -g -O2 -c init_nloptr.c -o init_nloptr.o
gcc -std=gnu99 -I"/opt/R/4.0.0/lib/R/include" -DNDEBUG -I../inst/include -I'/opt/R/4.0.0/lib/R/library/testthat/include' -I/usr/local/include -fpic -g -O2 -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/opt/R/4.0.0/lib/R/include" -DNDEBUG -I../inst/include -I'/opt/R/4.0.0/lib/R/library/testthat/include' -I/usr/local/include -fpic -g -O2 -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/opt/R/4.0.0/lib/R/include" -DNDEBUG -I../inst/include -I'/opt/R/4.0.0/lib/R/library/testthat/include' -I/usr/local/include -fpic -g -O2 -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/opt/R/4.0.0/lib/R/lib -L/usr/local/lib -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -L/opt/R/4.0.0/lib/R/lib -lRlapack -L/opt/R/4.0.0/lib/R/lib -lRblas -lgfortran -lm -lquadmath -Lnlopt/lib -lnlopt -L/opt/R/4.0.0/lib/R/lib -lR
/bin/ld: cannot find -lnlopt
collect2: error: ld returned 1 exit status
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/opt/R/4.0.0/lib/R/library/nloptr’
ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
* removing ‘/opt/R/4.0.0/lib/R/library/lme4’
ERROR: dependency ‘lme4’ is not available for package ‘pbkrtest’
* removing ‘/opt/R/4.0.0/lib/R/library/pbkrtest’
ERROR: dependencies ‘pbkrtest’, ‘lme4’ are not available for package ‘car’
* removing ‘/opt/R/4.0.0/lib/R/library/car’
ERROR: dependency ‘car’ is not available for package ‘rstatix’
* removing ‘/opt/R/4.0.0/lib/R/library/rstatix’
ERROR: dependency ‘car’ is not available for package ‘FactoMineR’
* removing ‘/opt/R/4.0.0/lib/R/library/FactoMineR’
ERROR: dependency ‘rstatix’ is not available for package ‘ggpubr’
* removing ‘/opt/R/4.0.0/lib/R/library/ggpubr’
ERROR: dependencies ‘FactoMineR’, ‘ggpubr’ are not available for package ‘factoextra’
* removing ‘/opt/R/4.0.0/lib/R/library/factoextra’
The downloaded source packages are in
‘/tmp/Rtmp98DJqK/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning messages:
1: In install.packages("factoextra") :
installation of package ‘nloptr’ had non-zero exit status
2: In install.packages("factoextra") :
installation of package ‘lme4’ had non-zero exit status
3: In install.packages("factoextra") :
installation of package ‘pbkrtest’ had non-zero exit status
4: In install.packages("factoextra") :
installation of package ‘car’ had non-zero exit status
5: In install.packages("factoextra") :
installation of package ‘rstatix’ had non-zero exit status
6: In install.packages("factoextra") :
installation of package ‘FactoMineR’ had non-zero exit status
7: In install.packages("factoextra") :
installation of package ‘ggpubr’ had non-zero exit status
8: In install.packages("factoextra") :
installation of package ‘factoextra’ had non-zero exit status

I solved this problem by sudo apt-get install libnlopt-dev.

so,
I think I finally figure out!
factoextra (or better, nloptr) currently needs a combination of
R v. >= 4 (not trial for centos! https://stackoverflow.com/a/67341871 )
cmake v. >= 3 (yum install cmake3 -- credits to https://github.com/astamm/nloptr/issues/104#issuecomment-1034229550)

In Ubuntu install cmake v3.20.2 from the source and it will solve the issue:
sudo apt install build-essential libssl-dev
wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz
tar -zxvf cmake-3.20.2.tar.gz
cd cmake-3.20.2
./bootstrap
make
sudo make install

Related

Error installing Hmisc package in R Studio

I'm new in R and I've been having some issues installing Hmisc package in order to elaborate a Spearman's correlation heatmap. The warning and error are as follows:
18 warnings generated.
gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls -fPIC -Wall -g -O2 -c bilinear.f -o bilinear.o
make: gfortran: No such file or directory
make: *** [bilinear.o] Error 1
ERROR: compilation failed for package ‘interp’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/interp’
Warning in install.packages :
installation of package ‘interp’ had non-zero exit status
* installing *source* package ‘polspline’ ...
** package ‘polspline’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls -fPIC -Wall -g -O2 -c allpack.f -o allpack.o
make: gfortran: No such file or directory
make: *** [allpack.o] Error 1
ERROR: compilation failed for package ‘polspline’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/polspline’
Warning in install.packages :
installation of package ‘polspline’ had non-zero exit status
* installing *source* package ‘VGAM’ ...
** package ‘VGAM’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c VGAM_init.c -o VGAM_init.o
clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c caqo3.c -o caqo3.o
gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls -fPIC -Wall -g -O2 -c ei.f -o ei.o
make: gfortran: No such file or directory
make: *** [ei.o] Error 1
ERROR: compilation failed for package ‘VGAM’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/VGAM’
Warning in install.packages :
installation of package ‘VGAM’ had non-zero exit status
ERROR: dependency ‘interp’ is not available for package ‘latticeExtra’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/latticeExtra’
Warning in install.packages :
installation of package ‘latticeExtra’ had non-zero exit status
ERROR: dependency ‘latticeExtra’ is not available for package ‘Hmisc’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Hmisc’
Warning in install.packages :
installation of package ‘Hmisc’ had non-zero exit status
ERROR: dependencies ‘Hmisc’, ‘polspline’ are not available for package ‘rms’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rms’
Warning in install.packages :
installation of package ‘rms’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/8b/43x_77fx1p73gb68h2418m5r0000gn/T/RtmpIhACeD/downloaded_packages.
PS. I'm also a Mac user, and I've trying to solve it as some of you guys have suggested in other similar questions,
I've used:
-adding dependencies=true in the script.
-installing tydiverse package
-installing backports

Issues installing RcppMP in MacOS

I am trying to install RcppMP in MacOS.
However, when I type:
remotes::install_github("Thell/RcppMP",dependencies = T)
I get the following error:
* installing *source* package ‘RcppMP’ ...
** using staged installation
** libs
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/ -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/BH/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:
In file included from ./../inst/include/RcppMP.h:7:
In file included from ../inst/include/RcppMP_RcppExports.h:7:
../inst/include/RcppMP_types.hpp:15:10: fatal error: 'mpreal.h' file not found
#include <mpreal.h>
^~~~~~~~~~
1 error generated.
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘RcppMP’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppMP’
Warning message:
In i.p(...) :
installation of package ‘/var/folders/pq/hxwd9my563q_qpy4rbrlgkmw0000gn/T//RtmpIdnyiB/file2184610d74ea/RcppMP_0.1.1.tar.gz’ had non-zero exit status
My ~/.R/Makevars file contain the following specifications:
CC=/usr/local/opt/llvm/bin/clang
CXX=/usr/local/opt/llvm/bin/clang++
CXX1X=/usr/local/opt/llvm/bin/clang++
LDFLAGS=-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib
CXXFLAGS=-I/usr/local/opt/llvm/include
FLIBS=-L/usr/local/Cellar/gcc/11.3.0_1/lib/gcc/11
This was a bit more complicated than I thought; this package requires mpfr, gmp and the very-similarly-named mpfrc++. The steps that worked for me are:
Install gmp and mpfr via homebrew
Download and unzip "mpfrc++-3.6.8.zip" from
http://www.holoborodko.com/pavel/mpfr/#download
Copy the mpreal header file ("mpreal.h") to
/usr/local/include (sudo cp ./mpreal.h /usr/local/include/) or, in your case, perhaps sudo cp ./mpreal.h /usr/local/opt/llvm/include would make more sense
Install/compile RcppMP
(remotes::install_github("Thell/RcppMP",dependencies = TRUE))
I got some warnings but no errors, and the package loaded (library(RcppMP)), so I'm relatively confident it installed successfully. If you find otherwise, please let me know and I'll look into it further.

fatal error installing systemfonts in jupyter R docker

I am running jupyterlabs on docker and wanted to install the rvg package. One of the dependencies are systemfonts, and when I tried to install this using install.packages("systemfonts") I get:
Warning: unable to access index for repository https://cran.yu.ac.kr/src/contrib:
cannot open URL 'https://cran.yu.ac.kr/src/contrib/PACKAGES'
Warning message:
package ‘systemfonts’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
So I downloaded the tar.gz file from CRAN and installed from file, but I get a fatal error:
> install.packages("systemfonts_1.0.2.tar.gz", repo = NULL, type = "source")
* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lfontconfig -lfreetype
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o font_fallback.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
x86_64-conda-linux-gnu-c++ -std=gnu++11 -I"/opt/conda/lib/R/include" -DNDEBUG -I'/opt/conda/lib/R/library/cpp11/include' -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /opt/conda/include -I/opt/conda/include -Wl,-rpath-link,/opt/conda/lib -fpic -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /opt/conda/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/r-base-split_1607284869564/work=/usr/local/src/conda/r-base-4.0.3 -fdebug-prefix-map=/opt/conda=/usr/local/src/conda-prefix -c caches.cpp -o caches.o
In file included from caches.h:7,
from caches.cpp:1:
ft_cache.h:9:10: fatal error: ft2build.h: No such file or directory
9 | #include <ft2build.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [/opt/conda/lib/R/etc/Makeconf:181: caches.o] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/opt/conda/lib/R/library/systemfonts’
Warning message:
In install.packages("work/corehead_data/systemfonts_1.0.2.tar.gz", :
installation of package ‘work/corehead_data/systemfonts_1.0.2.tar.gz’ had non-zero exit status
I tried to follow this SO Post, by typing in sudo apt-get install -y libfreetype6 to get freetype, but it is already the newest version. I'm not sure what else to try, hopefully someone can provide some expertise. Thanks.
Searching for "ft2build.h: No such file or directory Ubuntu" leads to this issue on systemfonts library GitHub where a workaround for the compilation error for Ubuntu 20.04 is shown:
sudo apt-get update
sudo apt-get install libfontconfig1-dev
This should help you to compile library from the tar.gz source.

installation package "tm" fails

I am trying to install package "tm" and get an error (see below). From this error I can't see what is going wrong. Package Rcpp is installed. Working on R 3.4.0, Xubuntu 64.
How can I install package tm?
* installing *source* package ‘tm’ ...
** package ‘tm’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/home/henk/R/x86_64-pc-linux-gnu-library/3.4/BH/include" -I"/home/henk/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
In file included from /home/henk/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include/Rcpp.h:34:0,
from RcppExports.cpp:4:
/home/henk/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include/Rcpp/grow.h:73:47: fatal error: Rcpp/generated/grow__pairlist.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:168: recipe for target 'RcppExports.o' failed
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘tm’
* removing ‘/home/henk/R/x86_64-pc-linux-gnu-library/3.4/tm’
Warning in install.packages :
installation of package 'tm' had non-zero exit status
The downloaded source packages are in
'/tmp/Rtmp3tKSat/downloaded_packages'
At first we can install "devtools" packages and than install "tm"
by using devtools::install_cran("tm")
try
sudo apt-get install r-cran-rcpp

installing venneuler and/or rJava R package

I'm trying to install the venneuler R package on linux.
Running: install.packages("venneuler") gives this error:
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
ERROR: configuration failed for package ârJavaâ
* removing â/home/nruns/R/rJavaâ
Warning in install.packages :
installation of package ârJavaâ had non-zero exit status
ERROR: dependency ârJavaâ is not available for package âvenneulerâ
* removing â/home/nruns/R/venneulerâ
Warning in install.packages :
installation of package âvenneulerâ had non-zero exit status
The downloaded source packages are in
â/tmp/RtmpjiRTHN/downloaded_packagesâ
Trying to install the rJava package produces the same error.
So I then run R CMD javareconf as suggested and get this error:
trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
#include <jni.h>
I updated java using:
sudo yum install java-1.8.0-openjdk
which completed fine but am still getting the same error trying to install venneuler
Any idea?
For rjava try installing following packages. It helped me
libbz2-dev
libpcre3-dev or libpcre2-dev
liblzma-dev
sudo apt-get install packagename

Resources