Not able to install packages on RStudio Server - r

I am using RStudio Server and trying to install basic packages and getting the below error -
g++ -I/usr/lib64/microsoft-r/3.3/lib64/R/include -DNDEBUG -
I../inst/include/ -DU_STATIC_IMPLEMENTATION -fpic -
DU_STATIC_IMPLEMENTATIN -O2 -g -c Date.cpp -o Date.o
sh: g++: command not found
make: *** [Date.o] Error 127
ERROR: compilation failed for package ‘Rcpp’
Does anyone face the same issue ? Please advise what needs to be done to resolve this.

sh: g++: command not found
You should install development tools suite first, then back to install the packag again.
On Ubuntu, you can try:
sudo apt-get install build-essential
On CentOS, you can try:
yum groupinstall "Development Tools"

Related

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.

R cannot find g77

I am trying to install from Cran the R package "fGarch", using install.packages('fGarch') I am on Ubuntu, I have r-base-dev and r-base-core installed.
But the install fails because:
77 -fno-optimize-sibling-calls -fpic -g -O2 -fdebug-prefix-map=/build/r-base-ttHamR/r-base-4.0.2=. -fstack-protector-strong -c dist.f -o dist.o
/bin/bash: 77: command not found
/usr/lib/R/etc/Makeconf:190: recipe for target 'dist.o' failed
make: *** [dist.o] Error 127
I have gfortran, gcc, g++. I also have something called "f77".
which f77
/usr/bin/f77
But nothing simply called "77". I do not understand what R is trying to call with "77".
I also installed the package from apt-get, but this then returns an error in R saying the version is too old and I should reinstall it.
Thank you for any help.

Torch '!./install.sh' returns error in Colab when installing Torch

I followed http://torch.ch/docs/getting-started.html#_ to install Torch.
I always get the following error when running
!./install.sh
in google colab
error:
...
-- Installing: /root/torch/install/include/luaT.h
-- Installing: /root/torch/install/share/cmake/torch/luaTConfig.cmake
Updating manifest for /root/torch/install/lib/luarocks/rocks
torch scm-1 is now built and installed in /root/torch/install/ (license: BSD)
Updating manifest for /root/torch/install/lib/luarocks/rocks
dok scm-1 is now built and installed in /root/torch/install/ (license: BSD)
gcc -O2 -fPIC -I/root/torch/install/include -c utils.c -o utils.o
gcc -shared -o treplutils.so -L/root/torch/install/lib utils.o
gcc -O2 -fPIC -I/root/torch/install/include -c readline.c -o readline.o
readline.c:8:10: fatal error: readline/readline.h: No such file or directory
#include <readline/readline.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Error: Build error: Failed compiling object readline.o
.
Please I need help fixing this error.
Probably you need something like
!apt-get install libreadline-dev
before attempting to run the install.sh script.

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

R: upgrading Hmisc on Debian Lenny

When I bring up a basic image of Debian Lenny on EC2 (actually EMR on EC2) I get Lenny version 5.0.7 and I am able to upgrade R using the method outlined in a previous question. After upgrading R I have version 2.12.
I've been unable to then install the Hmisc package. I see that it has a Debian package so I've tried:
sudo apt-get update
sudo apt-get install r-cran-hmisc
Which seems to work, but when I go into R I get the following:
> require(Hmisc)
Loading required package: Hmisc
Failed with error: ‘package 'Hmisc' was built before R 2.10.0: please re-install it’
so I presume the Hmisc in the Debian repo is an old version. So I'll just upgrade. So I go into R and:
install.packages("Hmisc")
which fails with:
...
gcc -I/usr/share/R/include -fpic -std=gnu99 -O3 -pipe -g -c string_box.c -o string_box.o
gfortran -fpic -O3 -pipe -g -c wclosest.f -o wclosest.o
gcc -shared -o Hmisc.so Hmisc.o cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o mChoice.o nstr.o ranksort.o rcorr.o string_box.o wclosest.o -lgfortran -lm -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
collect2: ld returned 1 exit status
make: *** [Hmisc.so] Error 1
ERROR: compilation failed for package ‘Hmisc’
* removing ‘/home/hadoop/R/x86_64-pc-linux-gnu-library/2.12/Hmisc’
The downloaded packages are in
‘/tmp/Rtmp2Ej5Tn/downloaded_packages’
Warning message:
In install.packages("Hmisc") :
installation of package 'Hmisc' had non-zero exit status
>
It appears like ld is struggling with lgfortran. I checked and gfortran is installed. So I tried installing gfortran-4.1:
sudo apt-get install gfortran-4.1
That didn't change anything. Nor did installing 4.2.
Any tips on what to try next?
What happens when you install the r-base-dev package? Does it build then? It should.
I stumbled upon this previous question right after I posted here. It appears I need to manually link to the gfortran libraries:
sudo ln -s /usr/lib/libgfortran.so.3 /usr/lib/libgfortran.so
After updating the cluster package I am able to install.packages("Hmisc")

Resources