Install rgdal in rstudio-server through Docker - rstudio-server

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")

Related

when trying to install rgeos R cannot find -lgeos

I am trying to install rgeos in R 3.5.1 running in ubuntu 16.04. When I run
install.packages("rgeos")
I get the following message:
* installing *source* package ‘rgeos’ ...
** package ‘rgeos’ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgeos: 0.4-1
checking for /usr/bin/svnversion... yes
configure: svn revision: 579
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS version: 3.5.1
checking geos version at least 3.2.0... yes
checking geos-config clibs... yes
checking geos_c.h presence and usability... yes
checking geos: linking with libgeos_c... no
/usr/bin/ld: cannot find -lgeos
collect2: error: ld returned 1 exit status
configure: Install failure: compilation and/or linkage problems.
configure: error: initGEOS_r not found in libgeos_c.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/3.5/rgeos’
Warning in install.packages :
installation of package ‘rgeos’ had non-zero exit status
I tried installing geospatial libraries
sudo apt-get install binutils libproj-dev gdal-bin
but it didn't help
Any help would be apprecieated
Same problem with R 3.5.1. This fixed the issue
sudo apt install libgeos++-dev

Install R serve on RHEL 7.5

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

Compilation failed for package ... from GitHub

I am trying to install a package from GitHub using devtools.
library("devtools")
install_github("tchakravarty/DCS")
but it gives me the following:
Downloading GitHub repo tchakravarty/DCS#master
from URL https://api.github.com/repos/tchakravarty/DCS/zipball/master
Installing DCS
"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \
"C:/Users/Alex S/AppData/Local/Temp/Rtmp0gaVCB/devtools1790c6de55/tchakravarty-DCS-bcb00ac" \
--library="C:/Users/Alex S/Documents/R/win-library/3.4" --install-tests
* installing *source* package 'DCS' ...
** libs
*** arch - i386
C:/RBUILD~1/3.4/mingw_32/bin/g++ -I"C:/PROGRA~1/R/R-34~1.3/include" -DNDEBUG -I"C:/Users/Alex S/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/Alex S/Documents/R/win-library/3.4/RcppArmadillo/include" -O2 -Wall -mtune=generic -c GaussianCopulaGASModel.cpp -o GaussianCopulaGASModel.o
C:/RBUILD~1/3.4/mingw_32/bin/g++ -I"C:/PROGRA~1/R/R-34~1.3/include" -DNDEBUG -I"C:/Users/Alex S/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/Alex S/Documents/R/win-library/3.4/RcppArmadillo/include" -O2 -Wall -mtune=generic -c MarkedPointProcess.cpp -o MarkedPointProcess.o
MarkedPointProcess.cpp:14:1: error: 'arma' does not name a type
arma::vec SimulateMarkedPointProcess(arma::vec vEta, arma::mat mAlpha, arma::vec vOmega,
^
make: *** [MarkedPointProcess.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-34~1.3/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-34~1.3/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="DCS.dll" OBJECTS="GaussianCopulaGASModel.o MarkedPointProcess.o RcppExports.o"' had status 2
ERROR: compilation failed for package 'DCS'
* removing 'C:/Users/Alex S/Documents/R/win-library/3.4/DCS'
In R CMD INSTALL
Installation failed: Command failed (1)
Initially I thought it could be that I have different versions of R and Rtools so I made sure that I have latest versions of both (also updated R studio).
Also tried installing a different package from GitHub
install_github("kbroman/broman")
works just fine. Any ideas why? Can it be that the package I am failing to install from GitHub is outdated?
Would be grateful for any help.

Problems installing R package "devtools" on Ubuntu 16.04 (Xenial)

I installed RStudio and R on Ubuntu 16.04 (Xenial) Linux:
user#machine:~/.Rlibs$ R --version
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
My problem is that I am not able to install package "devtools". I get a series of errors and all my attempts to install required dependencies failed so far. It seems that packages cannot be found even though they are installed.
I would be really grateful for any help!
The errors occur when trying to install the "devtools" package in RStudio or using the R console:
install.packages("devtools")
These are the errors I am getting (leaving out the download output):
* installing *source* package ‘mime’ ...
** package ‘mime’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c rawmatch.c -o rawmatch.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:132: recipe for target 'rawmatch.o' failed
make: *** [rawmatch.o] Error 1
ERROR: compilation failed for package ‘mime’
* removing ‘/home/user/.Rlibs/mime’
Warning in install.packages :
installation of package ‘mime’ had non-zero exit status
* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
* deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
* rpm: libcurl-devel (Fedora, CentOS, RHEL)
* csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘curl’
* removing ‘/home/user/.Rlibs/curl’
Warning in install.packages :
installation of package ‘curl’ had non-zero exit status
* installing *source* package ‘openssl’ ...
** package ‘openssl’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-lssl -lcrypto
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
* deb: libssl-dev (Debian, Ubuntu, etc)
* rpm: openssl-devel (Fedora, CentOS, RHEL)
* csw: libssl_dev (Solaris)
* brew: openssl (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘openssl’
* removing ‘/home/user/.Rlibs/openssl’
Warning in install.packages :
installation of package ‘openssl’ had non-zero exit status
* installing *source* package ‘digest’ ...
** package ‘digest’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c aes.c -o aes.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:132: recipe for target 'aes.o' failed
make: *** [aes.o] Error 1
ERROR: compilation failed for package ‘digest’
* removing ‘/home/user/.Rlibs/digest’
Warning in install.packages :
installation of package ‘digest’ had non-zero exit status
* installing *source* package ‘jsonlite’ ...
** package ‘jsonlite’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -Iyajl/api -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c base64.c -o base64.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:132: recipe for target 'base64.o' failed
make: *** [base64.o] Error 1
ERROR: compilation failed for package ‘jsonlite’
* removing ‘/home/user/.Rlibs/jsonlite’
Warning in install.packages :
installation of package ‘jsonlite’ had non-zero exit status
* installing *source* package ‘git2r’ ...
** package ‘git2r’ successfully unpacked and MD5 sums checked
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing inflate... no
configure: error: in `/tmp/RtmpMyvGHt/R.INSTALL4c4a1e9555fc/git2r':
configure: error:
---------------------------------------------
The zlib library that is required to build
git2r was not found.
Please install:
zlib1g-dev (package on e.g. Debian and Ubuntu)
zlib-devel (package on e.g. Fedora, CentOS and RHEL)
and try again.
If the zlib library is installed on your
system but the git2r configuration is
unable to find it, you can specify the
include and lib path to zlib with:
R CMD INSTALL --configure-args='--with-zlib-include=INCLUDE_PATH --with-zlib-lib=LIB_PATH' git2r
---------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘git2r’
* removing ‘/home/user/.Rlibs/git2r’
Warning in install.packages :
installation of package ‘git2r’ had non-zero exit status
ERROR: dependencies ‘jsonlite’, ‘mime’, ‘curl’, ‘openssl’ are not available for package ‘httr’
* removing ‘/home/user/.Rlibs/httr’
Warning in install.packages :
installation of package ‘httr’ had non-zero exit status
ERROR: dependency ‘digest’ is not available for package ‘memoise’
* removing ‘/home/user/.Rlibs/memoise’
Warning in install.packages :
installation of package ‘memoise’ had non-zero exit status
ERROR: dependencies ‘httr’, ‘memoise’, ‘digest’, ‘jsonlite’, ‘git2r’ are not available for package ‘devtools’
* removing ‘/home/user/.Rlibs/devtools’
Warning in install.packages :
installation of package ‘devtools’ had non-zero exit status
I noticed the following error:
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
I experienced the same issue when I wanted to use an outdated version of gcc (specifically, 4.8) to resolve some compatibility issues in one of my projects. The compiler flags "-Wdate-time" and "-fstack-protector-strong" are not available in older gcc releases. A similar flag "-fstack-protector-all" is available in some older gcc releases though.
To wrap up, this error messages is due to the fact that the developers expected an up-to-date gcc and used compiler flags for that up-to-date gcc version, but the gcc installed in your system was outdated.
Hope that helps other who might run into this issue in the future.

R - Error installing Devtools in Windows

I'm reasonably new to R, and to stackoverflow, so apologies if I have not provided sufficient detail in my question below. Happy to provide more info if required
I run Windows 7 Professional (64 bit) and have R version 3.0.2 installed.
When I try to install devtools, I obtain
library(devtools)
Warning message:
package ‘devtools’ was built under R version 3.0.3
build_github_devtools()
"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" --vanilla CMD SHLIB foo.c
gcc -m64 -I"C:/PROGRA~1/R/R-30~1.2/include" -DNDEBUG
-I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -std=gnu99 -mtune=core2 -c foo.c -o foo.o gcc -m64 -shared -s -static-libgcc -o foo.dll tmp.def foo.o -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-30~1.2/bin/x64 -lR Downloading devtools from https://github.com/hadley/devtools/archive/master.zip
"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" --vanilla CMD INSTALL
"C:\Users\AppData\Local\Temp\Rtmp8yGaPd\devtools-master" --build
installing to library 'C:/Users/AppData/Local/Temp/Rtmp8yGaPd/file1afc11f24d1b'
ERROR: dependencies 'rversions', 'git2r' are not available for package
'devtools'
removing 'C:/Users/AppData/Local/Temp/Rtmp8yGaPd/file1afc11f24d1b/devtools'
Error: Command failed (1)
I've searched for help on dependencies rversions and git2r but no luck so far.
Can anybody help please?
This is information about git2r
The following devtools installation information comes from devtools:
Make sure you have a working development environment.
Windows: Install Rtools.
Install the release version of devtools from CRAN with install.packages("devtools").
Windows:
library(devtools)
build_github_devtools()
Restart R before continuing
install.packages("devtools.zip", repos = NULL, type = "source")
Remove the package after installation
unlink("devtools.zip")

Resources