rgeos package installation error on linux [R] - r

I'm trying to install the package rgeos on linux. I get the following error:
system("sudo apt-get update")
system("sudo apt install libgdal-dev -y")
install.packages("rgeos")
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’
I have already install the dev libgdal and it returns the "already installed" info if I try to run the sudo again.
How can I fix this? Thanks in advance!

It is a bug, you could use this to install lower stable version.
install.packages("devtools")
library(devtools)
install_version("rgeos", version = "0.3-28")
After this code all should be fine.

Related

Unable to install package "quanteda.textstats" in R under Ubuntu 22.04.1 LTS

I am trying to install the package quanteda.textstats in R under Ubuntu Version 22.04.1 LTS.
I initially ran:
install.packages("quanteda.textstats")
where I got an error message saying it could not install the dependency proxyC. I was able to install that, but I still get an error message when running the above code.
/usr/bin/ld: cannot find -llapack: No such file or directory
/usr/bin/ld: cannot find -lblas: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: quanteda.textstats.so] Error 1
ERROR: compilation failed for package ‘quanteda.textstats’
* removing ‘/home/user/R/x86_64-pc-linux-gnu-library/4.2/quanteda.textstats’
Warning in install.packages :
installation of package ‘quanteda.textstats’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpuUtAq1/downloaded_packages’
I would guess I am missing certain dependencies, but I am unable to figure out what -llapack and -lblas stands for.
I also tried running the github install (option 3):
remotes::install_github("quanteda/quanteda.textstats")
but there as well I get a similar error:
/usr/bin/ld: cannot find -llapack: No such file or directory
/usr/bin/ld: cannot find -lblas: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: quanteda.textstats.so] Error 1
ERROR: compilation failed for package ‘quanteda.textstats’
* removing ‘/home/user/R/x86_64-pc-linux-gnu-library/4.2/quanteda.textstats’
Warning message:
In i.p(...) :
installation of package ‘/tmp/RtmpuUtAq1/file17581cc7f39c/quanteda.textstats_0.96.tar.gz’ had non-zero exit status
Can anybody help please?
Your are trying to compile the package which requires to have certain system dependencies installed, in this case lblas and llapack. This is not the recommended way to install R packages on Ubuntu. Instead you should install them as PPAs as described on CRAN.
If you insist on compiling the package yourself, install the dependencies via apt in the system terminal:
sudo apt-get install libblas-dev liblapack-dev

ERROR: compilation failed for package ‘xml2’

I am installing "rvest" and "xml2" packages in Ubuntu 16.04. But on multiple times i am getting the error as below
/usr/lib/R/etc/Makeconf:143: recipe for target 'connection.o' failed
make: *** [connection.o] Error 1
ERROR: compilation failed for package ‘xml2’
* removing ‘/home/prdmcl/R/x86_64-pc-linux-gnu-library/3.2/xml2’
Warning in install.packages :
installation of package ‘xml2’ had non-zero exit status
I checked multiple sources and did this also
sudo apt-get install libcurl4-openssl-dev libssl-dev
sudo apt-get install libxml2-dev
But failed to install.
Seems to be a specific problem with your system(mainly with C++), not with the package.
I had the same problem, and I used this workaround on R command line :
withr::with_makevars(c(CXX = "g++ -std=c++11"),install.packages("xml2", verbose = TRUE))
This will install xml2. After that, you can install rvest package

problem installing ComplexHeatmap. ERROR: compilation failed for package ‘cluster’

i am installing an R package called complex heatmaps (https://jokergoo.github.io/ComplexHeatmap-reference/book/). I get this error. So far i just identified it might be do to this package : https://packages.debian.org/buster/r-cran-cluster but i am not sure what to do at all. Thats why i am writing you.
Thanks a lot for your help
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'cluster.so' failed
make: *** [cluster.so] Error 1
ERROR: compilation failed for package ‘cluster’
* removing ‘/home/luca/R/x86_64-pc-linux-gnu-library/3.6/cluster’
Error: Failed to install 'ComplexHeatmap' from GitHub:
(converted from warning) installation of package ‘cluster’ had non-zero exit status
The error message indicates that you are missing libfortran.so. You might even miss more tools necessary for installing R packages from source. How to install this depends on the Linux distribution you are using. For Debian, which you mention in the question, this would be
sudo apt install r-base-dev
If you want to speed up package installation, you can also use the binary packages available in Debian, i.e.
sudo apt install r-cran-cluster

rgdal installation error: core dumped when finalizing install

I'm currently using linux subsystem on Windows.
Few days ago I've installed microsoft-r and RStudio and tried to install a rgdal package(ultimately I will install tmap and tmaptools packages). Of course, libgdal-dev and its dependencies are correctly configured in the way I've known.
Here's a error message when R finalizes the installation of rgdal: (truncated)
*** installing vignettes
** testing if installed package can be loaded
sh: line 1: 8835 aborted (core dumped) '/usr/lib64/microsoft-r/3.4/lib64/R/bin/R' --no-save --slave 2>&1 < '/tmp/RtmpDpn26L/file1f726636ef3e'
ERROR: loading failed
* removing '/home/felix/R/x86_64-pc-linux-gnu-library/3.4/rgdal'
Warning in install packages:
installation of package 'rgdal' had non-zero exit status
`
Does anyone have a similar experience like my case?
Thanks in advance.

cannot install R tseries, quadprog ,xts packages in Linux

I am using R version 3.4.0
I'm trying to install tseries package on linux machine:
install.packages('https://cran.cnr.berkeley.edu/src/contrib/tseries_0.10-42.tar.gz',dependencies = TRUE,repos = NULL,type ="source")
It gives error:
ERROR: compilation failed for package 'xts'
* removing '/usr/lib64/R/library/xts'
ERROR: dependency 'xts' is not available for package 'TTR'
* removing '/usr/lib64/R/library/TTR'
ERROR: dependencies 'xts', 'TTR' are not available for package 'quantmod'
* removing '/usr/lib64/R/library/quantmod'
ERROR: dependencies 'quadprog', 'quantmod' are not available for package 'tseries'
* removing '/usr/lib64/R/library/tseries'
1: In install.packages("tseries", dependencies = TRUE) :
installation of package 'quadprog' had non-zero exit status
2: In install.packages("tseries", dependencies = TRUE) :
installation of package 'xts' had non-zero exit status
3: In install.packages("tseries", dependencies = TRUE) :
installation of package 'TTR' had non-zero exit status
4: In install.packages("tseries", dependencies = TRUE) :
installation of package 'quantmod' had non-zero exit status
5: In install.packages("tseries", dependencies = TRUE) :
installation of package 'tseries' had non-zero exit status
Then I tried installing quadprog using:
install.packages('https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz',dependencies = TRUE,repos = NULL,type ="source")
It gives error :
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [quadprog.so] Error 1
ERROR: compilation failed for package 'quadprog'
* removing '/usr/lib64/R/library/quadprog'
Please help what should i do. I'm facing hard time in installing these packages.
I have installed R using :
sudo yum -y install R-core R-devel
I tried installing gfortran using : yum install gcc-gfortran
It says :Package gcc-gfortran-4.4.7-18.el6.x86_64 already installed and latest version
Nothing to do
The problem here is that the Fortran compiler (gfortran) and the GCC compiler driver (gcc) are out of sync: gfortran is version 4.4.7, gcc is version 4.7.2. This means that they use different directories to store there files, and gcc is unable to locate the libgfortran.so symbolic link installed by the gcc-gfortran package.
The solution is to bring these two compilers to the same version. This can be achieved by adjusting the PATH variable (based on other discussions, gcc is not referring to /usr/bin/gcc here), deinstalling the software collection that provides this gcc command (using yum remove devtoolset-1.1-gcc), or installing the Fortran component for the same software collection, using yum install devtoolset-1.1-gcc-gfortran.
My best guess is that your devtoolset-1.1-gcc package comes from this repository:
https://people.centos.org/tru/devtools-1.1/6/x86_64/RPMS/
So you could use the gfortran package from there, too (and pick the c++ package as well, to avoid a similar problem).
After spending quite some time with the same error, the only solution that worked for me was to re-install all R components.
For completness, what I did was to remove all R components with:
dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | sudo xargs apt-get remove --purge -y (got it from here)
and re-install R again: sudo apt-get install r-base r-base-dev
I fixed this by reinstalling R from source using:
make install rhome=/usr

Resources