ERROR: compilation failed for package ‘xml2’ - r

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

Related

Trying to get Tidyverse installed in Linux mint 20.2

I've been working on getting RStudio to open on and off for the last few days, finally got it running and started installing packages. Readr installed fine but tidyverse refuses to install.
/usr/bin/ld: /usr/local/lib/libcrypto.a(v3_genn.o): relocation R_X86_64_PC32 against symbol `GENERAL_NAME_it' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: openssl.so] Error 1
ERROR: compilation failed for package ‘openssl’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/openssl’
Warning in install.packages :
installation of package ‘openssl’ had non-zero exit status
ERROR: dependency ‘openssl’ is not available for package ‘ids’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/ids’
Warning in install.packages :
installation of package ‘ids’ had non-zero exit status
ERROR: dependency ‘openssl’ is not available for package ‘httr’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/httr’
Warning in install.packages :
installation of package ‘httr’ had non-zero exit status
ERROR: dependency ‘httr’ is not available for package ‘gargle’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/gargle’
Warning in install.packages :
installation of package ‘gargle’ had non-zero exit status
ERROR: dependency ‘httr’ is not available for package ‘rvest’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/rvest’
Warning in install.packages :
installation of package ‘rvest’ had non-zero exit status
ERROR: dependencies ‘gargle’, ‘httr’ are not available for package ‘googledrive’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/googledrive’
Warning in install.packages :
installation of package ‘googledrive’ had non-zero exit status
ERROR: dependencies ‘gargle’, ‘googledrive’, ‘httr’, ‘ids’ are not available for package ‘googlesheets4’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/googlesheets4’
Warning in install.packages :
installation of package ‘googlesheets4’ had non-zero exit status
ERROR: dependencies ‘googledrive’, ‘googlesheets4’, ‘httr’, ‘rvest’ are not available for package ‘tidyverse’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/tidyverse’
Warning in install.packages :
installation of package ‘tidyverse’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpyoCTNu/downloaded_packages’
To fix this I've tried suggestions from two places:
The first option was 'sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev'
from this website: https://blog.zenggyu.com/en/post/2018-01-29/installing-r-r-packages-e-g-tidyverse-and-rstudio-on-ubuntu-linux/
The second this was 'sudo apt-get install r-base-dev xml2 libxml2-dev libssl-dev libcurl4-openssl-dev unixodbc-dev'
from the rstudio community page: https://community.rstudio.com/t/cant-install-tidyverse/29293
A third option I found that is too advanced for me without guidance is this:
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=...'
I'm sure I'm doing something wrong. I think something may not be in the proper place or is linked to the wrong location. Any assistance would be greatly appreciated.
(Also,for reference, this is the first time I've used linux so please dumb answers down as much as possible)
I've now gotten this to work. By looking at the error messages I found the dependencies that need to be installed before tidyverse can be installed (and function).
It is preferable but not necessary to get the latest version of R installed. I followed the steps in this tutorial:
https://linuxconfig.org/how-to-install-rstudio-on-ubuntu-20-04-focal-fossa-linux
In the interest of putting everything in one place, I'll put the steps here:
Step 1:
$ sudo apt update
$ sudo apt -y install r-base gdebi-core
Step 2: Install Rstudio from their website
Step 3: For this step, make sure you're in the folder that has the file downloaded, for me that was in downloads
$ sudo gdebi rstudio-1.2.5019-amd64.deb
Step 4: Open Rstudio
To get tidyverse to work, my error messages were all about non-zero exit statuses. What I did was to go through, find the packages that weren't properly installing, and manually install them.
My first problem was with curl. I tried installing it in Rstudio first. When I got an error, I went into terminal and installed it with
sudo apt-get install libcurl4-openssl-dev
If openssl refuses to install try:
sudo apt-get install libssl-dev
I tried installing tidyverse again, no dice. It was still having trouble with xml2 and rvest. I installed xml2 in terminal with.
sudo apt-get install libxml2-dev
After that, rvest installed using Rstudio and tidyverse installed successfully.
These instructions work with both R 4.1.1 and R 3.4.4
It would seem that the R version here is quite old, version 3.6. A bunch of things that are tidyverse related broke around the switch from 3.* to 4.*.
If you follow a procedure like this, it should get you started on the right path with the proper R version and the rest will likely fall into place.
https://linuxize.com/post/how-to-install-r-on-ubuntu-20-04/
Occasionally, on linux machines, you will have packages that fail to install because of system level dependencies that are missing. Those messages are usually informative; they will tell you what you need and the command for acquiring it.

error in install.packages 'rgdal': gdal-config not found - configure argument error

I am trying to install rgdal package in rstudio. I am using centos8. I have already installed:
sudo yum install gdal gdal-devel
sudo yum install geos geos-devel
I have also tried to install using:
install.packages('rgdal', type = "source", configure.args=c(
'--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config',
'--with-proj-include=/Library/Frameworks/PROJ.framework/Headers',
'--with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'))
My error message:
configure: error: gdal-config not found - configure argument error.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/motipai/R/x86_64-redhat-linux-gnu-library/4.0/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp5jeQl8/downloaded_packages’
installing first in terminal:
sudo yum install gdal.x86_64 gdal-devel.x86_64 gdal-libs.x86_64
sudo yum install proj.x86_64 proj-devel.x86_64
and then in r console:
install.packages("rgdal")
Solves the probem.

install daewr package in R 4.0

hi i am trying to install package for experiment designs like this
install.packages("daewr", dependencies = T)
but it returns the following
configure: error: GNU MP not found, or not 4.1.4 or up, see http://gmplib.org
ERROR: configuration failed for package ‘gmp’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/gmp’
Warning in install.packages :
installation of package ‘gmp’ had non-zero exit status
ERROR: dependency ‘gmp’ is not available for package ‘partitions’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/partitions’
Warning in install.packages :
installation of package ‘partitions’ had non-zero exit status
ERROR: dependency ‘partitions’ is not available for package ‘DoE.base’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/DoE.base’
Warning in install.packages :
installation of package ‘DoE.base’ had non-zero exit status
ERROR: dependency ‘DoE.base’ is not available for package ‘FrF2’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/FrF2’
Warning in install.packages :
installation of package ‘FrF2’ had non-zero exit status
ERROR: dependency ‘FrF2’ is not available for package ‘daewr’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/daewr’
Warning in install.packages :
installation of package ‘daewr’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpB1bSe0/downloaded_packages’
so i decided to download the file from https://cran.r-project.org/web/packages/daewr/index.html
after trying to install it returns me
also installing the dependencies ‘gmp’, ‘partitions’, ‘DoE.base’, ‘FrF2.catlg128’
I try to install the first one but it asks for a Bessel package and it still gives me problems
I solved it by installing dependency one by one, many answer you install the dependencies but they do not say how I will explain them for the new ones in linux and in R to install the daerw package with the aforementioned problems, install the following in the linux console
sudo apt-get install libgsl-dev
with that install libraries now I can open R and install
install.packages('gsl')
then I opened the linux console again and installed
sudo apt-get install libgmp-dev
I go back to R and install
install.packages("gmp", dependencies = T)
now I can install the package without problems
install.packages("daewr", dependencies = T)
library(daewr)
I hope that any comment is welcome.

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

installation of package ‘devtools’ had non-zero exit status on Ubuntu

I'm trying to install devtools in a PowerPC with a R version 3.1.1 but failed at the end because the curl library:
...
** testing if installed package can be loaded Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/path
to/R/powerpc-unknown-linux-gnu-library/3.1/curl/libs/curl.so': /path
to/R/powerpc-unknown-linux-gnu-library/3.1/curl/libs/curl.so:
undefined symbol: BSWAP_32 Error: loading failed Execution halted
ERROR: loading failed
* removing ‘/path to/R/powerpc-unknown-linux-gnu-library/3.1/curl’ ERROR: dependency ‘curl’ is not available for package ‘httr’
* removing ‘/path to/R/powerpc-unknown-linux-gnu-library/3.1/httr’ ERROR: dependency ‘curl’ is not available for package ‘rversions’
* removing ‘/path to/R/powerpc-unknown-linux-gnu-library/3.1/rversions’ ERROR:
dependencies ‘httr’, ‘rversions’ are not available for package
‘devtools’
* removing ‘/path to/R/powerpc-unknown-linux-gnu-library/3.1/devtools’
The downloaded source packages are in
‘/tmp/RtmpD0yE63/downloaded_packages’ Warning messages: 1: In
install.packages("devtools") : installation of package ‘curl’ had
non-zero exit status 2: In install.packages("devtools") :
installation of package ‘httr’ had non-zero exit status 3: In
install.packages("devtools") : installation of package ‘rversions’
had non-zero exit status 4: In install.packages("devtools") :
installation of package ‘devtools’ had non-zero exit status
I've already installed libcurl4-gnutls-dev and libcurl4-openssl-dev and the libcurl version is 7.38.0.
Does anyone know a fix to this? Thanks ;)
The same problem happened to me when I was trying to install "devtools" package on a new machine with Ubuntu 16.04 system.
I tried many answers including the adopted one above, but I still couldn't solve the problem until I noticed another warning information "(as ‘lib’ is unspecified)". Then I realized that I was running R as a normal user while the R base is installed by root. It means the package "devtools" couldn't be installed into the default R library folder and possibly couldn't use some dependent packages. Then the solution became very easy: run R as root user and then install "devtools".
Following the instructions of Dean Attali (https://www.digitalocean.com/community/tutorials/how-to-set-up-r-on-ubuntu-14-04), I summarize the steps below. Just run them in a terminal.
$ sudo apt-get -y install libcurl4-gnutls-dev libxml2-dev libssl-dev
$ sudo su
$ R
> install.packages('devtools', repos='http://cran.rstudio.com/')
That's it. Since the package is installed by root, it can be used by all users of the system.
For Curl use:
apt-get -y build-dep libcurl4-gnutls-dev
apt-get -y install libcurl4-gnutls-dev
And you should update the R version to R-3.1.2
wget http://cran.r-project.org/src/base/R-3/R-3.1.2.tar.gz
I m using Ubuntu 16.04 and this is how I solved this issue:
aptitude install libssl-dev
then aptitude packg manage will allow you to choose the right version which is required for installation of devtools.
Repeat the same for
aptitude libcurl4-gnutls-dev
aptitude libxml2-dev
Finally, install this libgit2 lib
devtools::install_github('ropensci/git2r')
devtools::load_all()
R CMD INSTALL git2r
I could not solve it with apt-get packg manager. Thats all :) !
This error was happening when I was using 3.0.2. I updated the R, now It is fine. I also spent the one day to find the solution. I tried the all the solution. But, no effect. I updated the R using this solution. Now, devtools package is working.
Fedora 34
What did it for me was:
sudo dnf groupinstall "Development tools"
Not sure about that, but also:
sudo dnf install freetype-devel libpng-devel libtiff-devel libjpeg-turbo-devel
Don't know, don't care, but it worked!

Resources