Science_blog: How to install R library 'tidyverse' for updated R version 4.2.1 on latest Ubuntu 22.2

Search This Blog

Thursday, 16 February 2023

How to install R library 'tidyverse' for updated R version 4.2.1 on latest Ubuntu 22.2

Dear all,

I was trying to install tidyverse in Rv4.2.1 in Ubuntu 22.2 ans whenever i as trying to install tidyverse I got an error "ERROR: configuration failed for package ‘curl’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/curl’

Warning in install.packages :

  installation of package ‘curl’ had non-zero exit status

* installing *source* package ‘xml2’ ...

** package ‘xml2’ successfully unpacked and MD5 sums checked

** using staged installation

Package libxml-2.0 was not found in the pkg-config search path.

Perhaps you should add the directory containing `libxml-2.0.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libxml-2.0' found

Package libxml-2.0 was not found in the pkg-config search path.

Perhaps you should add the directory containing `libxml-2.0.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libxml-2.0' found

Using PKG_CFLAGS=

Using PKG_LIBS=-lxml2

------------------------- ANTICONF ERROR ---------------------------

Configuration failed because libxml-2.0 was not found. Try installing:

 * deb: libxml2-dev (Debian, Ubuntu, etc)

 * rpm: libxml2-devel (Fedora, CentOS, RHEL)

 * csw: libxml2_dev (Solaris)

If libxml-2.0 is already installed, check that 'pkg-config' is in your

PATH and PKG_CONFIG_PATH contains a libxml-2.0.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 ‘xml2’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/xml2’

Warning in install.packages :

  installation of package ‘xml2’ had non-zero exit status

ERROR: dependency ‘curl’ is not available for package ‘httr’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/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/rajiv/R/x86_64-pc-linux-gnu-library/4.2/gargle’

Warning in install.packages :

  installation of package ‘gargle’ had non-zero exit status

ERROR: dependencies ‘httr’, ‘xml2’ are not available for package ‘rvest’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/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/rajiv/R/x86_64-pc-linux-gnu-library/4.2/googledrive’

Warning in install.packages :

  installation of package ‘googledrive’ had non-zero exit status

ERROR: dependencies ‘curl’, ‘gargle’, ‘googledrive’, ‘httr’ are not available for package ‘googlesheets4’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/googlesheets4’

Warning in install.packages :

  installation of package ‘googlesheets4’ had non-zero exit status

ERROR: dependencies ‘googledrive’, ‘googlesheets4’, ‘httr’, ‘rvest’, ‘xml2’ are not available for package ‘tidyverse’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/tidyverse’

Warning in install.packages :

  installation of package ‘tidyverse’ had non-zero exit status

"

#############################################################################

Well, to solve this i googled and got some way thereafter i tried myself. So solution is here:

1. > find("install.packages")

then i got 

[1] "package:utils"

2. > sessionInfo()

then i got 

R version 4.2.1 (2022-06-23)

Platform: x86_64-pc-linux-gnu (64-bit)

Running under: Ubuntu 22.10

Matrix products: default

BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.1

LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.1

locale:

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=de_DE.UTF-8       

 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8   

 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                  LC_ADDRESS=C              

[10] LC_TELEPHONE=C             LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):

[1] compiler_4.2.1 tools_4.2.1   


Unfortunately, tidyverse is not installed.

Well, i again i googled.


3. > utils::install.packages("tidyverse")

I got this error

ERROR: configuration failed for package ‘curl’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/curl’

* installing *source* package ‘xml2’ ...

** package ‘xml2’ successfully unpacked and MD5 sums checked

** using staged installation

Package libxml-2.0 was not found in the pkg-config search path.

Perhaps you should add the directory containing `libxml-2.0.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libxml-2.0' found

Package libxml-2.0 was not found in the pkg-config search path.

Perhaps you should add the directory containing `libxml-2.0.pc'

to the PKG_CONFIG_PATH environment variable

No package 'libxml-2.0' found

Using PKG_CFLAGS=

Using PKG_LIBS=-lxml2

------------------------- ANTICONF ERROR ---------------------------

Configuration failed because libxml-2.0 was not found. Try installing:

 * deb: libxml2-dev (Debian, Ubuntu, etc)

 * rpm: libxml2-devel (Fedora, CentOS, RHEL)

 * csw: libxml2_dev (Solaris)

If libxml-2.0 is already installed, check that 'pkg-config' is in your

PATH and PKG_CONFIG_PATH contains a libxml-2.0.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 ‘xml2’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/xml2’

ERROR: dependency ‘curl’ is not available for package ‘httr’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/httr’

ERROR: dependency ‘httr’ is not available for package ‘gargle’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/gargle’

ERROR: dependencies ‘httr’, ‘xml2’ are not available for package ‘rvest’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/rvest’

ERROR: dependencies ‘gargle’, ‘httr’ are not available for package ‘googledrive’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/googledrive’

ERROR: dependencies ‘curl’, ‘gargle’, ‘googledrive’, ‘httr’ are not available for package ‘googlesheets4’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/googlesheets4’

ERROR: dependencies ‘googledrive’, ‘googlesheets4’, ‘httr’, ‘rvest’, ‘xml2’ are not available for package ‘tidyverse’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/tidyverse’


The downloaded source packages are in

‘/tmp/RtmpAPocAk/downloaded_packages’

Warning messages:

1: In utils::install.packages("tidyverse") :

  installation of package ‘curl’ had non-zero exit status

2: In utils::install.packages("tidyverse") :

  installation of package ‘xml2’ had non-zero exit status

3: In utils::install.packages("tidyverse") :

  installation of package ‘httr’ had non-zero exit status

4: In utils::install.packages("tidyverse") :

  installation of package ‘gargle’ had non-zero exit status

5: In utils::install.packages("tidyverse") :

  installation of package ‘rvest’ had non-zero exit status

6: In utils::install.packages("tidyverse") :

  installation of package ‘googledrive’ had non-zero exit status

7: In utils::install.packages("tidyverse") :

  installation of package ‘googlesheets4’ had non-zero exit status

8: In utils::install.packages("tidyverse") :

  installation of package ‘tidyverse’ had non-zero exit status

...................................................................................................................................

4. So, i tried to install Rculr througn Rconsol

> install.packages("RCurl")

and geot this error 

ERROR: dependency ‘curl’ is not available for package ‘httr’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/httr’

ERROR: dependency ‘httr’ is not available for package ‘gargle’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/gargle’

ERROR: dependency ‘httr’ is not available for package ‘rvest’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/rvest’

ERROR: dependencies ‘gargle’, ‘httr’ are not available for package ‘googledrive’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/googledrive’

ERROR: dependencies ‘curl’, ‘gargle’, ‘googledrive’, ‘httr’ are not available for package ‘googlesheets4’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/googlesheets4’

ERROR: dependencies ‘googledrive’, ‘googlesheets4’, ‘httr’, ‘rvest’ are not available for package ‘tidyverse’

* removing ‘/home/rajiv/R/x86_64-pc-linux-gnu-library/4.2/tidyverse’

5. Then i  tried with linux terminal 

6. sudo apt-get update

7. sudo apt-get install libxml2-dev

8. sudo apt-get install r-cran-xml

9. sudo apt-get install libcurl4-openssl-dev r-base

10. R -q -e "install.packages(c('curl'))"

11. sudo apt install r-cran-curl

12. Then again I tried 

> utils::install.packages("tidyverse")

and got no error 

13. then 

> library('tidyverse')

and showed 

── Attaching packages ───────────────────────────────────────────────── tidyverse 1.3.2 ──

✔ ggplot2 3.4.1     ✔ purrr   1.0.1

✔ tibble  3.1.8     ✔ dplyr   1.1.0

✔ tidyr   1.3.0     ✔ stringr 1.5.0

✔ readr   2.1.4     ✔ forcats 1.0.0

── Conflicts ──────────────────────────────────────────────────── tidyverse_conflicts() ──

✖ dplyr::filter() masks stats::filter()

✖ dplyr::lag()    masks stats::lag()


Hurreyyyyyyyy!!!!!!!!!!!!


So the problem was not with R updated version. Indeed, it was problem with Ubuntu new version 22.2. Hence, you need to install Rcurl through terminal first then try by R consol.

Ubuntu does not allow any progrram directly. It reueirs lib files which were missing in updated version. So, first update ubuntu through terminal and then install lib files.


Refernces:

https://stackoverflow.com/questions/52082543/curl-package-not-available-for-several-r-packages

https://stackoverflow.com/questions/7765429/unable-to-install-r-package-in-ubuntu-11-04

https://stackoverflow.com/questions/20671814/non-zero-exit-status-r-3-0-1-xml-and-rcurl

https://stackoverflow.com/questions/72578482/issues-installing-tidyverse-package






No comments:

Post a Comment

Multidisciplinary Mega‑Journals: Has Their Time Passed?

     Over the past decade, multidisciplinary and so‑called “mega‑journals” became some of the most attractive destinations for researchers u...