Errors in installing R packages on Linux server

Hi I am using linux remote server (ubuntu 22) where i got admin access recently. I reinstalled latest R 4.4.1 and rstudio server but there is problem installing R packages.

[1] "/home/sfar/R/x86_64-pc-linux-gnu-library/4.4"
[2] "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"
[4] "/usr/lib/R/library"```
When installing packages XML was not found  and when I tried to install XML it gives
```Installing package into ‘/home/sfar/R/x86_64-pc-linux-gnu-library/4.4’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/XML_3.99-0.17.tar.gz'
Content type 'application/x-gzip' length 968686 bytes (945 KB)
==================================================
downloaded 945 KB

* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
** using staged installation
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 the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... 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 directory of LIBXML_INCDIR
Located parser file /usr/include/libxml2/parser.h
Checking for 1.8:  /usr/include/libxml2
Using libxml2.*
checking for gzopen in -lz... no
checking for xmlParseFile in -lxml2... no
checking for xmlParseFile in -lxml... no
configure: error: "libxml not found"
ERROR: configuration failed for package ‘XML’
* removing ‘/home/sfar/R/x86_64-pc-linux-gnu-library/4.4/XML’

The downloaded source packages are in
        ‘/tmp/RtmpmwDpKm/downloaded_packages’
Warning message:
In install.packages("XML") :
  installation of package ‘XML’ had non-zero exit status```

Hi @mfar1
Welcome to the Community Forum.

At the Linux terminal install the missing OS package libxml
sudo apt install libxml
Then try again to install the XML R package.

Some R packages need system libraries on Linux. You can use the pak package to look up the system libraries they need, or even automatically install them: System requirements — System requirements • pak

Install pak:

install.packages("pak", repos = sprintf(
  "https://r-lib.github.io/p/pak/stable/%s/%s/%s",
  .Platform$pkgType,
  R.Version()$os,
  R.Version()$arch
))

(All about installing pak. — Installing pak • pak)

Then to install R packages, with system libs, assuming you have password-less sudo or you are the root user:

pak::pkg_install("XML")

To only look up the system dependencies for your system:

pak::pkg_sysreqs("XML")

or for another system:

❯ pak::pkg_sysreqs("XML", sysreqs_platform = "ubuntu-22.04")
── Install scripts ───────────────────────────────────────────── Ubuntu 22.04 ──
apt-get -y update
apt-get -y install libxml2-dev

── Packages and their system dependencies ──────────────────────────────────────
XML – libxml2-dev
1 Like

Hi, thank you for the helpful response. XML installed and some packages also installed but couple of packages couldn't install with following output at the end

* removing ‘/home/saad/R/x86_64-pc-linux-gnu-library/4.4/DMRcate’

The downloaded source packages are in
        ‘/tmp/Rtmp9eaMbT/downloaded_packages’
Installation paths not writeable, unable to update packages
  path: /usr/lib/R/library
  packages:
    boot, codetools, foreign, lattice, Matrix, nlme, spatial
Warning messages:
1: In install.packages(...) :
  installation of package ‘missMethyl’ had non-zero exit status
2: In install.packages(...) :
  installation of package ‘DMRcate’ had non-zero exit status```

That seems like output from install.packages(), but it is impossible to tell what went wrong without seeing the rest of the output.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.