Installed R 3.4.1 in RHEL 7.5(maipo) by using the below commands
wget https://cran.r-project.org/src/base/R-3/R-3.4.1.tar.gz
tar xvzf R-3.4.1.tar.gz
cd R-3.4.1
yum groupinstall "Development Tools"
yum install ncurses-devel zlib-devel texinfo gtk+-devel gtk2-devel qt-devel tcl-devel tk-devel kernel-headers kernel-devel readline-devel
yum install bzip2-devel
yum install xz xz-devel
yum -y install libcurl libcurl-devel
yum install java-1.8.0-openjdk-devel
yum install gsl-devel
yum install openssl-devel
yum install libcurl-devel
yum install pulseaudio-libs-devel
yum install python-devel
yum install glibc-static
yum install glibc-devel
yum install libbz2-dev
yum install zlib-devel glibc
./configure --enable-R-shlib --with-readline=no --with-x=no
make
make install
Then i tried to install Rserve
by install.packages("Rserve")
It reports as below
sha1.o standalone.o tls.o ulog.o utils.o websockets.o winembed.o -lssl -lcrypto -ldl -lcrypt -L/usr/local/lib64/R/lib -lR
/bin/ld: cannot find -lR
collect2: error: ld returned 1 exit status
make: *** [Rserve.so] Error 1
ERROR: compilation failed for package ‘Rserve’
* removing ‘/usr/local/lib64/R/library/Rserve’
Can any one help me on this ?
Not an answer but to long for a comment:
I have tried to reproduce this using this Docker file:
FROM centos:7.5.1804
RUN yum -y groupinstall "Development Tools" \
&& yum -y install ncurses-devel zlib-devel texinfo gtk+-devel gtk2-devel qt-devel \
tcl-devel tk-devel readline-devel bzip2-devel xz xz-devel \
libcurl libcurl-devel java-1.8.0-openjdk-devel gsl-devel \
openssl-devel libcurl-devel pulseaudio-libs-devel python-devel \
glibc-static glibc-devel libbz2-dev zlib-devel glibc
RUN yum -y install wget \
&& wget https://cran.r-project.org/src/base/R-3/R-3.4.1.tar.gz \
&& tar xvzf R-3.4.1.tar.gz \
&& cd R-3.4.1 \
&& ./configure --enable-R-shlib --with-readline=no --with-x=no \
&& make \
&& make install
RUN Rscript -e 'install.packages("Rserve", repo="https://cloud.r-project.org/")'
However, for me libR is created and and the Docker image is build without problem:
$ docker run --rm centos-r ls /usr/local/lib64/R/lib
libR.so
libRblas.so
libRlapack.so
Some further ideas:
Are you sure you used a freshly unpacked source directory?
Can't you simply use the R packages provided by EPEL?
Follow the installation instructions from RStudio:
enable EPEL
yum-builddep R
./configure --enable-R-shlib ...
Related
I have a problem building a docker image with the following codes:
FROM rocker/verse:latest
MAINTAINER xxx
RUN apt-get update \
&& apt-get install -y --no-install-recommends apt-utils ed libnlopt-dev libgdal-dev libudunits2-dev cargo jags libcairo2-dev libxt-dev libgeos-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
# Install rstan
RUN install2.r --error --deps TRUE \
rstan \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
# Global site-wide config -- neeeded for building packages
RUN mkdir -p $HOME/.R/ \
&& echo "CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -flto -ffat-lto-objects -Wno-unused-local-typedefs \n" >> $HOME/.R/Makevars
# Config for rstudio user
RUN mkdir -p $HOME/.R/ \
&& echo "CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -flto -ffat-lto-objects -Wno-unused-local-typedefs -Wno-ignored-attributes -Wno-deprecated-declarations\n" >> $HOME/.R/Makevars \
&& echo "rstan::rstan_options(auto_write = TRUE)\n" >> /home/rstudio/.Rprofile \
&& echo "options(mc.cores = parallel::detectCores())\n" >> /home/rstudio/.Rprofile
RUN Rscript -e "install.packages('cmdstanr', repos = 'http://cran.us.r-project.org', dependencies=TRUE)"
# Install rstan
RUN install2.r --error --deps TRUE \
rstan \
loo \
bayesplot \
rstanarm \
rstantools \
shinystan \
ggmcmc \
tidybayes \
LaplacesDemon \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
RUN install2.r --error --deps TRUE \
zoo \
mgcv \
lubridate \
stringr \
loo \
jsonlite \
scales \
directlabels \
betareg \
extrafont \
pointdensityP \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
# Install Roboto condensed
RUN wget -O /tmp/rc.zip https://fonts.google.com/download?family=Roboto%20Condensed \
&& cd /usr/share/fonts \
&& sudo mkdir googlefonts \
&& cd googlefonts \
&& sudo unzip -d . /tmp/rc.zip \
&& sudo chmod -R --reference=/usr/share/fonts/truetype /usr/share/fonts/googlefonts \
&& sudo fc-cache -fv \
&& rm -rf /tmp/rc.zip \
&& Rscript --slave --no-save --no-restore-history -e "extrafont::font_import(prompt=FALSE)"
And I failed to build the docker image with the following error:
#10 224.1 Error: dependency ‘cmdstanr’ is not available------executor failed running [/bin/sh -c install2.r --error --deps TRUE rstan loo bayesplot rstanarm rstantools shinystan ggmcmc tidybayes LaplacesDemon && rm -rf /tmp/downloaded_packages/ /tmp/*.rds]: exit code: 1
Can anyone help me with the issue?
The Getting Started with CmdStanR vignette says you should use
install.packages("cmdstanr",
repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
you're trying to install it from a CRAN mirror, which won't work because the package isn't on CRAN. (I haven't tested, you might want to install cmdstanr after you install Stan ...
This is my lifecycle configuration for the Notebook but raster fails in the install step....
I have taken some recommendations from the following thread where they install dependencies related to geospatial processing but without much success
github thead
I am also incorporating EPEL, which aws recommends for these cases.
sudo -b yum --enablerepo=epel
I install all the libraries in the conda R environment
set -e
# OVERVIEW
# This script installs a single conda R package (bigmemory) in SageMaker R environment.
# To install an R package with conda, the package needs to be prefixed with 'r-'. For example, to install the package `shiny`, run 'conda install -c r r-shiny'.
nohup sudo -b -u ec2-user -i <<'EOF'
nohup sudo -b yum --enablerepo=epel
# First, we need to install the lustre-client libraries
# https://stackoverflow.com/questions/20923209/problems-installing-the-devtools-package
nohup sudo -b yum install -y \
libgeos \
libgdal-dev \
libgeos-dev \
libproj-dev \
libgdal-devel \
libgeos-devel \
libproj-devel \
libcurl \
libcurl-devel \
openssl-devel \
libxml2-devel
echo "PASS STAGE 1 "
# libgdal1 libgdal1-dev libgeos libgeos-dev
source activate R
nohup conda install -y -c r r-binutils &
nohup conda install -y -c r r-libgit2 &
nohup conda install -y -c r r-libxml2-devel &
nohup conda install -y -c r r-devtools &
nohup conda install -y -c r r-remotes &
nohup conda install -y -c r r-units &
nohup conda install -y -c r r-sf &
nohup conda install -y -c r r-terra &
nohup conda install -y -c r r-spData &
nohup conda install -y -c r r-spdep &
nohup conda install -y -c r r-raster & ##this can not install
nohup conda install -y -c r r-reshape2 &
nohup conda install -y -c r r-DescTools &
nohup conda install -y -c r r-spdep &
nohup conda install -y -c r r-xgboost &
nohup conda install -y -c r r-dplyr &
nohup conda install -y -c r r-readr &
nohup conda install -y -c r r-readxl &
nohup conda install -y -c r r-paws &
nohup conda install -y -c r r-botor &
echo "PASS STAGE 2 "
#outForest
nohup conda install -y -c r r-RcppEigen &
nohup conda install -y -c r r-FNN &
nohup conda install -y -c r r-ranger &
nohup conda install -y -c r r-missRanger &
nohup conda install -y -c r r-outForest &
echo "PASS STAGE 3 "
conda deactivate
well finaly the succesfull script here
one important point is use a text editor compatible with unix return carriage
Important
When you create or change a script, we recommend that you use a text editor that provides Unix-style line breaks, such as the text editor available in the console when you create a notebook. Copying text from a non-Linux operating system might introduce incompatible line breaks and result in an unexpected error.
#!/bin/bash
set -e
sudo -u ec2-user -i <<'EOF'
nohup yum -y install gcc gcc-c++ clang libcurl-devel openssl-devel | "FAIL LINUX DEPS"
source activate R
nohup conda install -y -c r r-sf &
nohup conda install -y -c r r-raster=3.4-10 &
nohup conda install -y -c r r-dplyr &
nohup conda install -y -c r r-readr &
nohup conda install -y -c r r-readxl &
nohup conda install -y -c r r-paws &
nohup conda install -y -c r r-botor &
conda deactivate
EOF
AWS LifeCicleConf
while installing rstan getting following error:
Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined
from research got to know that C++14 compiler should be available.
How to install the same while configuring R.
Using the below command to configure R
./configure --with-readline=no --with-x=no
and installing
yum install -y devtoolset-6
but still not able to update C++14 and rstan gives the error
Default C++ compiler: g++ -g -O2
C++98 compiler: g++ -g -O2
C++11 compiler: g++ -std=gnu++11 -g -O2
C++14 compiler: g++ -g -O2
C++17 compiler:
Fortran 90/95 compiler: gfortran -g -O2
Obj-C compiler:
setup.sh
yum -y update
yum install -y centos-release-scl
yum install -y devtoolset-6
yum install -y devtoolset-6-gcc-gfortran
scl enable devtoolset-6 bash
scl enable devtoolset-6-gcc-gfortran bash
mkdir packages
cd packages
wget -qO-
https://downloads.sourceforge.net/project/libpng/zlib/1.2.8/zlib-
1.2.8.tar.gz | tar zvx
cd zlib-1.2.8
./configure
make
make install
cd ..
wget -qO- http://downloads.sourceforge.net/pcre/pcre-8.35.tar.gz |
tar xzv
cd pcre-8.35
./configure
make
make install
cd ..
wget -qO- http://tukaani.org/xz/xz-5.2.2.tar.gz | tar xzv
cd xz-5.2.2
./configure
make
make install
cd ..
wget -qO- https://curl.haxx.se/download/curl-7.47.1.tar.gz | tar xzv
cd curl-7.47.1
./configure
make
make install
cd ..
wget -qO- https://cran.r-project.org/src/base/R-3/R-3.4.4.tar.gz |
tar xzv
cd R-3.4.4
./configure --with-readline=no --with-x=no --prefix=/packages/R-3.4.4
F77=gfortran
make
make install
I also got this problem, here I record how to solve it.
The key point is installing proper g++ and configure it.
Firstly, install g++ Version >= 5 as https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Linux said:
Using RStan requires either g++ version 4.9 and up
Here I am installing g++8 (You can change the version as your wish):
Run
$ sudo yum install centos-release-scl
$ sudo yum install devtoolset-8-gcc*
Now you have an alternative g++ along with default g++ in your OS.
You can enable this and check the version:
$ scl enable devtoolset-8 bash
$ gcc --version
$ g++ --version
Find its location:
$ which g++
/opt/rh/devtoolset-8/root/usr/bin/g++
Next, you need to configure ~/.R/Makevars, put the following content to it either using vim (or other editors):
CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=/opt/rh/devtoolset-8/root/usr/bin/g++
Or using R commands:
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native -fPIC",
"CXX14=/opt/rh/devtoolset-8/root/usr/bin/g++", # or clang++ but you may need a version postfix
file = M, sep = "\n", append = TRUE)
NOTE: these R commands are copied from https://github.com/stan-dev/rstan/wiki/Configuring-C-Toolchain-for-Linux but CXX14 flag is modified according to the location above.
Now, you can install rstan package now:
install.packages("rstan")
Hope this helps.
PS: R users can use this approach to modify the compiler flags in a similar way.
This is what worked for me:
CXX_STD = CXX14
CXX14 = g++ -std=c++11
CXX14FLAGS = -O3 -fPIC -Wno-unused-variable -Wno-unused-function -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION
You don't need to recompile R but you do need at least g++-4.9 (or clang++-3.4) and to define CXX14 = g++ in your ~/.R/Makevars configuration file. In addition, you usually need CXX14FLAGS = -fPIC and would be well advised to have CXX14FLAGS = -O3 -mtune = native -march = native -fPIC. There is a wiki page for all this.
did the following changes and now it's working fine. Need to define gcc PATH and used yum install -y devtoolset-6 for R-3.4.4. Thank you for help
yum install -y centos-release-scl
yum install -y devtoolset-6
yum install -y bzip2-devel
source scl_source enable devtoolset-6
also added the Path to gcc in build.sh
export PATH=/opt/rh/devtoolset-6/root/bin:$PATH
I had the same problem.
Here is my solution in case it helps others.
On CentOS 7, I:
installed V8 headers and shared library from here: https://pkgs.org/download/v8-devel 41 (EPEL_x86_64)
bumped gcc from version 4 to 9.3.1
In R, I:
removed rstan and StanHeaders
installed rstan and StanHeaders in a fresh R session
Posted discussion on Stan Forum here: https://discourse.mc-stan.org/t/problem-installing-rstan-2-21-using-r-4-0-1-on-centos-7/17784/9
Part of a Jenkins job I'm running entails installing rJava; the Jenkins job is running on a docker image over which I have control, but still I can't seem to get rJava to install.
Looking around a bit, it seems like being sure to run R CMD javareconf is pretty key in all this, and indeed I added && R CMD javareconf as the last command in my Dockerfile. Compilation of the Docker image contains:
Java interpreter : /docker-java-home/jre/bin/java
Java version : 1.8.0_171
Java home path : /docker-java-home
Java compiler : /docker-java-home/bin/javac
Java headers gen.: /docker-java-home/bin/javah
Java archive tool: /docker-java-home/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/docker-java-home/include -I/docker-java-home/include/linux -fpic -g -O2 -fdebug-prefix-map=/build/r-base-3.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-z,relro -o conftest.so conftest.o -L/docker-java-home/jre/lib/amd64/server -ljvm -L/usr/lib/R/lib -lR
JAVA_HOME : /docker-java-home
Java library path: $(JAVA_HOME)/jre/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib/R
Done.
Now, when I enter the Docker instance (docker exec -it jenkins_img bash), I can in fact manually install rJava: install.packages('rJava') works as expected; importantly, this is part of the output there:
checking Java support in R... present:
interpreter : '/docker-java-home/jre/bin/java'
archiver : '/docker-java-home/bin/jar'
compiler : '/docker-java-home/bin/javac'
header prep.: '/docker-java-home/bin/javah'
cpp flags : '-I/docker-java-home/include -I/docker-java-home/include/linux'
java libs : '-L/docker-java-home/jre/lib/amd64/server -ljvm'
However, when I run the script that's part of my Jenkins job, the corresponding output becomes:
checking Java support in R... present:
interpreter : '/usr/lib/jvm/default-java/jre/bin/java'
archiver : '/usr/lib/jvm/default-java/bin/jar'
compiler : '/usr/lib/jvm/default-java/bin/javac'
header prep.: '/usr/lib/jvm/default-java/bin/javah'
cpp flags : '-I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux'
java libs : '-L/usr/lib/jvm/default-java/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... ./configure: line 3747: /usr/lib/jvm/default-java/jre/bin/java: No such file or directory
no
configure: error: Java interpreter '/usr/lib/jvm/default-java/jre/bin/java' does not work
So, it seems whichever process is running when I docker exec to bash has a different JAVA_HOME than the process which is running under my Jenkins job. To that end, I added the following directly before the line installing rJava in my script (as suggested):
export JAVA_HOME=/docker-java-home/
export PATH=$PATH:$JAVA_HOME/bin
Rscript -e 'install.packages("rJava")'
However, this fails with the same output. I have also checked that the R process running install.packages has the same JAVA_HOME by cating Sys.getenv('JAVA_HOME') and confirming that it's /docker-java-home/.
The Jenkins script doesn't have root access so I can't run R CMD javareconf there.
How can I get install.packages('rJava') to use the right JAVA_HOME?
FWIW, these days I use some variation of the following in Docker images to get rJava to build correctly:
# rJava
RUN apt-get update && apt-get install -y libudunits2-dev gnupg2 software-properties-common
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" \
| tee /etc/apt/sources.list.d/webupd8team-java.list \
&& echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" \
| tee -a /etc/apt/sources.list.d/webupd8team-java.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 \
&& echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" \
| /usr/bin/debconf-set-selections \
&& apt-get update \
&& apt-get install -y oracle-java8-installer \
&& update-alternatives --display java \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& R CMD javareconf
This was not particularly my own work, I basically took it from #daroczig:
https://github.com/rocker-org/rocker/issues/109
https://hub.docker.com/r/cardcorp/r-java/dockerfile/
I am using the opencpu/rstudio docker image. Docker runs through a Virtual Machine because I am a Windows user. After running rstudio-server, I try to install my R package from github. Everything works fine, until rgdal should be installed.
I get the following error message:
Installing rgdal
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --
quiet \
CMD INSTALL '/tmp/RtmpJvVTTU/devtools2c362554e5/rgdal' \
--library='/usr/local/lib/opencpu/site-library' --install-tests
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 1.2-16
checking for /usr/bin/svnversion... no
configure: svn revision: 701
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/usr/local/lib/opencpu/site-library/rgdal’
Installation failed: Command failed (1)
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --
quiet \
CMD INSTALL \
'/tmp/RtmpJvVTTU/devtools2cd1cfd76/amun-software-Processingservice-6db3f06'
\
--library='/usr/local/lib/opencpu/site-library' --install-tests
How could I solve this?
There are some missing libraries.
If you log in to the shell of the Docker container as follows...
docker exec -it <your docker container name> bash
you can install the missing dependencies...
sudo apt-get update && sudo apt-get install libgdal-dev libproj-dev
Exit the shell and from RStudio do...
install.packages("rgdal")