Error installing R package for Linux - r

Im trying to install a package named "rgeos" on R 3.3, but when I type
install.packages("rgeos")
But it returns me the following error (same happens with other packages, but not all the packages):
> * installing *source* package ‘rgeos’ ...
** package ‘rgeos’ successfully unpacked and MD5 sums checked
configure: CC: gcc
configure: CXX: g++
configure: rgeos: 0.3-19
checking for /usr/bin/svnversion... no
configure: svn revision: 524
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/kdg/R/x86_64-pc-linux-gnu-library/3.3/rgeos’
>
> The downloaded source packages are in
> ‘/tmp/Rtmpsa5pDo/downloaded_packages’ Warning message: In
> install.packages("rgeos") : installation of package ‘rgeos’ had
> non-zero exit status
Any clues how con install this package?

It seems that when running R in Linux is necessary to install some build tools. As in this case, in the terminal:
sudo apt-get install libgeos-dev
Then try package install again.
hints from here

I solved it with the following:
cd /opt
git clone https://github.com/libgeos/geos
cd geos
export CC='clang' && export CXX='clang++' && export OBJC='clang'
./autogen.sh
./configure
make
sudo -EH make install
R
install.packages('rgeos')
NB: export clang is particular to me; I am just pasting my exact solution.

Related

“installation of package tuneR had non-zero exit status” in R

OS: Ubuntu 18.04
R version: 3.4.3 and 3.4.4
I tried to install tuneR with install.packages("tuneR") in R 3.4.3 and R 3.4.4 but I get this error:
* installing *source* package ‘signal’ ...
package ‘signal’ successfully unpacked and MD5 sums checked
libs
gfortran -fpic -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -c dpchim.f -o dpchim.o
/bin/bash: gfortran: command not found
/usr/lib/R/etc/Makeconf:182: recipe for target 'dpchim.o' failed
make: *** [dpchim.o] Error 127
ERROR: compilation failed for package ‘signal’
* removing ‘/home/helias/R/x86_64-pc-linux-gnu-library/3.4/signal’
ERROR: dependency ‘signal’ is not available for package ‘tuneR’
* removing ‘/home/helias/R/x86_64-pc-linux-gnu-library/3.4/tuneR’
The downloaded source packages are in
‘/tmp/RtmpL1f4HR/downloaded_packages’
Warning messages:
1: In install.packages("tuneR") :
installation of package ‘signal’ had non-zero exit status
2: In install.packages("tuneR") :
installation of package ‘tuneR’ had non-zero exit status
(I also used RStudio)
I solved installing gfortran and after re-run install.packages("tuneR")
sudo apt install gfortran
You can try downloading the source and install from RStudio. tuneR is available at:
https://CRAN.R-project.org/package=tuneR
Download the .tar.gz file and install locally. You can install using through RStudio (Packages tab -> change install from: Package), or you can install through the terminal using
R CMD INSTALL -l /path tuneR.tar.gz
Another option is
> library(devtools)
> install_github("cran/tuneR")

Installing the R-package "rgeos" on linux: geos-config not found or not executable

I am running R 3.4.1 on gentoo.
When i try to install the 'rgeos' package, i get this:
> install.packages("rgeos")
Installing package into ‘/home/jody/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://stat.ethz.ch/CRAN/src/contrib/rgeos_0.4-2.tar.gz'
Content type 'application/x-gzip' length 255244 bytes (249 KB)
==================================================
downloaded 249 KB
* installing *source* package ‘rgeos’ ...
** package ‘rgeos’ successfully unpacked and MD5 sums checked
configure: CC: x86_64-pc-linux-gnu-gcc
configure: CXX: x86_64-pc-linux-gnu-g++
configure: rgeos: 0.4-2
checking for /usr/bin/svnversion... yes
configure: svn revision: 581
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/jody/R/x86_64-pc-linux-gnu-library/3.4/rgeos’
The downloaded source packages are in
‘/tmp/RtmppEeDps/downloaded_packages’
Warning message:
In install.packages("rgeos") :
installation of package ‘rgeos’ had non-zero exit status
(The same happens if i try to install rgeos on gentoo with R 3.5.1, and also on Centos 7.5 with R 3.5.1.)
While there is a rgeos/configure which is executable in the tar file mentioned above, there is indeed no geos-config in there.
How can i get the rgeos package installed?
Is there perhaps a binary version which i could download?
For Ubuntu (19.10 and likely onward) use:
sudo apt install libgeos-dev
I found the solution.
The "rgeos" package depends on libraries you have to install before running R.
In gentoo i had to do:
sudo emerge --ask sci-libs/geos
In CentOS:
sudo yum install geos geos-devel
After installing these libraries i started R and could install the 'rgeos' package without problems
For Ubuntu 20.04, the solution is:
sudo apt install libgeos-dev
For Arch/Manjaro:
sudo pacman -S geos

More trouble Installing rgdal on ubuntu 16.04

This problem installing rgdal is not resolved in other similar questions already posted. I installed gdal using the advice on http://www.sarasafavi.com/installing-gdalogr-on-ubuntu.html and also decribed in other answers like this trouble in installing rgdal on ubuntu 16.04 that means from ppa:ubuntugis.
Then when I try to install rgdal the following error appears
> install.packages("rgdal")
Installing package into ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rgdal_1.3-4.tar.gz'
Content type 'application/x-gzip' length 1664774 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /usr/lib/R
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... no
configure: svn revision: 766
checking for gdal-config... /home/leonardo/anaconda3/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.2
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
/usr/bin/x86_64-linux-gnu-ld: warning: libproj.so.12, needed by /home/leonardo/anaconda3/lib/libgdal.so, not found (try using -rpath or -rpath-link)
/usr/bin/x86_64-linux-gnu-ld: warning: libpoppler.so.71, needed by /home/leonardo/anaconda3/lib/libgdal.so, not found (try using -rpath or -rpath-link)
/usr/bin/x86_64-linux-gnu-ld: warning: libxerces-c-3.2.so, needed by /home/leonardo/anaconda3/lib/libgdal.so,
...
500 lines more
...
/home/leonardo/anaconda3/lib/libgeos_c.so: undefined reference to `geos::geom::PrecisionModel::PrecisionModel(double)'
collect2: error: ld returned 1 exit status
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/3.5/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status
It seems to be a problem with python anaconda that I have previously installed, I removed the anaconda python gdal package using
conda remove gdal
But the problems persist
The only way to solve this was to completely remove anaconda installation, following the instructions on https://conda.io/docs/user-guide/install/linux.html#uninstalling-anaconda-or-miniconda with some minor modifications for ubuntu 16.04, you have to open a terminal and remove the anaconda install directory:
rm -rf ~/anaconda3
rm -rf ~/.condarc ~/.conda ~/.continuum
Edit ~/.bashrc to remove the anaconda directory from your PATH environment variable.
After that the installation of rgdal
install.packages("rgdal")
goes without problems.

Can not install Rcurl package on ubuntu, do I need curl configuration ? [R] [duplicate]

I am having a bit of trouble installing XML and RCurl on my Ubuntu machine 13.10. I performed all sudo update and upgrades today.
I am trying to use rattle for R. I am unable to install 'XML' which is required for the use of rattle. This is pretty much the same question that was asked right here just a year later and a different OS. Here are the error messages that I am getting back:
> install.packages("RCurl")
Installing package into ‘/home/steven/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RCurl_1.95-4.1.tar.gz'
Content type 'application/x-gzip' length 870915 bytes (850 Kb)
opened URL
==================================================
downloaded 850 Kb
* installing *source* package ‘RCurl’ ...
** package ‘RCurl’ successfully unpacked and MD5 sums checked
checking for curl-config... no
Cannot find curl-config
ERROR: configuration failed for package ‘RCurl’
* removing ‘/home/steven/R/x86_64-pc-linux-gnu-library/3.0/RCurl’
Warning in install.packages :
installation of package ‘RCurl’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpUwBkbS/downloaded_packages’
> install.packages("XML")
Installing package into ‘/home/steven/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/XML_3.98-1.1.tar.gz'
Content type 'application/x-gzip' length 1582216 bytes (1.5 Mb)
opened URL
==================================================
downloaded 1.5 Mb
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name...
rm: cannot remove 'a.out.dSYM': Is a directory
a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
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 how to run the C preprocessor... gcc -E
checking for sed... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking for xml2-config... no
Cannot find xml2-config
ERROR: configuration failed for package ‘XML’
* removing ‘/home/steven/R/x86_64-pc-linux-gnu-library/3.0/XML’
Warning in install.packages :
installation of package ‘XML’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpUwBkbS/downloaded_packages’
Not too sure on how to proceed from here.
To install curl and xml on Ubuntu. Run
sudo apt-get install libcurl4-openssl-dev libxml2-dev
The error messages on package install in R indicate that the curl and xml libraries are not present or cannot be found.
In CentOS 6+ you can do it using
sudo yum -y install curl
sudo yum -y install libcurl libcurl-devel
sudo yum -y install libxml2 libxml2-devel
For those who can't install using yum or apt-get, I share my experience:
I installed libcurl-openssl-dev myself by downloading the source code and compiling. I still ran into the Cannot find curl-config problem though...I didn't know what to do until looking at RCurl source code and seeing a CURL_CONFIG environment variable being referenced. I tried setting this myself in my .bashrc and it seems to have worked:
export CURL_CONFIG=~/my/libcurl/curl-config
for ubuntu 18.05 sometimes repository having issues run as per below
add below repository in sudoedited line
deb http://security.ubuntu.com/ubuntu bionic-security main
sudoedit /etc/apt/sources.list
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev --fix-broken
sudo apt-get install libcurl4-openssl-dev libxml2-dev
fix package name

Unable to install rgdal and rgeos R libraries on Red hat linux

I have error while compiling rgdal adn rgoes package on our redhat linux machine. I tried to do some research but couldn't find a possible solution. Could you please help me with this as this is very important for me to solve.
**ERROR WHILE COMPILING RGDAL in R 3.0**
**strong text**
* installing *source* package ârgdalâ ...
** package ârgdalâ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 0.8-10
checking for /usr/bin/svnversion... yes
configure: svn revision: 496
configure: gdal-config: gdal-config
checking gdal-config usability... ./configure: line 1397: gdal-config: command not found
no
Error: gdal-config not found
The gdal-config script distributed with GDAL could not be found.
If you have not installed the GDAL libraries, you can
download the source from http://www.gdal.org/
If you have installed the GDAL libraries, then make sure that
gdal-config is in your path. Try typing gdal-config at a
shell prompt and see if it runs. If not, use:
--configure-args='--with-gdal-config=/usr/local/bin/gdal-config'
with appropriate values for your installation.
ERROR: configuration failed for package ârgdalâ
*****ERROR WHILE COMPILING RGEOS:*****
**strong text**
* installing *source* package ârgeosâ ...
** package ârgeosâ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgeos: 0.2-17
checking for /usr/bin/svnversion... yes
configure: svn revision: 413M
checking geos-config usability... ./configure: line 1385: geos-config: command not found
no
configure: error: geos-config not usable
ERROR: configuration failed for package ârgeosâ
On fedora 20 you need to install geos and geos-devel !
sudo yum install geos geos-devel
After that the compilation in R work well!
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (gstat)
The downloaded source packages are in
‘/tmp/Rtmp9ciIzG/downloaded_packages’
I'm not on redhat (I'm on Ubuntu) so someone who is may be able to give better package names.. . But, when installing packages from source, you need the dev of the required libraries. In this case, you probably need to install:
libgdal1-dev
libgeos-dev
So:
yum install libgdal1 libgdal1-dev libgeos libgeos-dev
Then in R:
install.packages('gdal')
this is untested, since I don't want all the extra packages associated with those two!

Resources