Installing 'tidyverse' package for R/RStudio

With help from this forum, I was able to get R and RStudio working on Zorin 16 Lite. I now need to install the 'tidyverse' package for R, but attempting the install gives this error:

$ sudo R
(R starts up)
> install.packages("tidyverse")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: dependencies ‘MASS’, ‘lattice’ are not available
also installing the dependencies ‘nlme’, ‘Matrix’, ‘mgcv’, ‘systemfonts’, ‘textshaping’, ‘ggplot2’, ‘ragg’, ‘rvest’, ‘xml2’

trying URL 'https://cloud.r-project.org/src/contrib/nlme_3.1-163.tar.gz'
Content type 'application/x-gzip' length 848981 bytes (829 KB)
==================================================
downloaded 829 KB

trying URL 'https://cloud.r-project.org/src/contrib/Matrix_1.6-1.1.tar.gz'
Content type 'application/x-gzip' length 2065748 bytes (2.0 MB)
==================================================
downloaded 2.0 MB

trying URL 'https://cloud.r-project.org/src/contrib/mgcv_1.9-0.tar.gz'
Content type 'application/x-gzip' length 1112050 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

trying URL 'https://cloud.r-project.org/src/contrib/systemfonts_1.0.5.tar.gz'
Content type 'application/x-gzip' length 80638 bytes (78 KB)
==================================================
downloaded 78 KB

trying URL 'https://cloud.r-project.org/src/contrib/textshaping_0.3.7.tar.gz'
Content type 'application/x-gzip' length 35100 bytes (34 KB)
==================================================
downloaded 34 KB

trying URL 'https://cloud.r-project.org/src/contrib/ggplot2_3.4.4.tar.gz'
Content type 'application/x-gzip' length 3159578 bytes (3.0 MB)
==================================================
downloaded 3.0 MB

trying URL 'https://cloud.r-project.org/src/contrib/ragg_1.2.6.tar.gz'
Content type 'application/x-gzip' length 425391 bytes (415 KB)
==================================================
downloaded 415 KB

trying URL 'https://cloud.r-project.org/src/contrib/rvest_1.0.3.tar.gz'
Content type 'application/x-gzip' length 94659 bytes (92 KB)
==================================================
downloaded 92 KB

trying URL 'https://cloud.r-project.org/src/contrib/xml2_1.3.5.tar.gz'
Content type 'application/x-gzip' length 272664 bytes (266 KB)
==================================================
downloaded 266 KB

trying URL 'https://cloud.r-project.org/src/contrib/tidyverse_2.0.0.tar.gz'
Content type 'application/x-gzip' length 704618 bytes (688 KB)
==================================================
downloaded 688 KB

ERROR: dependency ‘lattice’ is not available for package ‘nlme’
* removing ‘/usr/local/lib/R/site-library/nlme’
ERROR: dependency ‘lattice’ is not available for package ‘Matrix’
* removing ‘/usr/local/lib/R/site-library/Matrix’
* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Package fontconfig was not found in the pkg-config search path.
Perhaps you should add the directory containing `fontconfig.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fontconfig' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lfontconfig -lfreetype
--------------------------- [ANTICONF] --------------------------------
Configuration failed to find the fontconfig freetype2 library. Try installing:
 * deb: libfontconfig1-dev (Debian, Ubuntu, etc)
 * rpm: fontconfig-devel (Fedora, EPEL)
 * csw: fontconfig_dev (Solaris)
 * brew: freetype (OSX)
If fontconfig freetype2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a fontconfig freetype2.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 MESSAGE] ---------------------------
<stdin>:1:10: fatal error: fontconfig/fontconfig.h: No such file or directory
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed for package ‘systemfonts’
* removing ‘/usr/local/lib/R/site-library/systemfonts’
* 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 ‘/usr/local/lib/R/site-library/xml2’
ERROR: dependencies ‘nlme’, ‘Matrix’ are not available for package ‘mgcv’
* removing ‘/usr/local/lib/R/site-library/mgcv’
ERROR: dependency ‘systemfonts’ is not available for package ‘textshaping’
* removing ‘/usr/local/lib/R/site-library/textshaping’
ERROR: dependency ‘xml2’ is not available for package ‘rvest’
* removing ‘/usr/local/lib/R/site-library/rvest’
ERROR: dependencies ‘MASS’, ‘mgcv’ are not available for package ‘ggplot2’
* removing ‘/usr/local/lib/R/site-library/ggplot2’
ERROR: dependencies ‘systemfonts’, ‘textshaping’ are not available for package ‘ragg’
* removing ‘/usr/local/lib/R/site-library/ragg’
ERROR: dependencies ‘ggplot2’, ‘ragg’, ‘rvest’, ‘xml2’ are not available for package ‘tidyverse’
* removing ‘/usr/local/lib/R/site-library/tidyverse’

The downloaded source packages are in
	‘/tmp/Rtmpr5gSsS/downloaded_packages’
Warning messages:
1: In install.packages("tidyverse") :
  installation of package ‘nlme’ had non-zero exit status
2: In install.packages("tidyverse") :
  installation of package ‘Matrix’ had non-zero exit status
3: In install.packages("tidyverse") :
  installation of package ‘systemfonts’ had non-zero exit status
4: In install.packages("tidyverse") :
  installation of package ‘xml2’ had non-zero exit status
5: In install.packages("tidyverse") :
  installation of package ‘mgcv’ had non-zero exit status
6: In install.packages("tidyverse") :
  installation of package ‘textshaping’ had non-zero exit status
7: In install.packages("tidyverse") :
  installation of package ‘rvest’ had non-zero exit status
8: In install.packages("tidyverse") :
  installation of package ‘ggplot2’ had non-zero exit status
9: In install.packages("tidyverse") :
  installation of package ‘ragg’ had non-zero exit status
10: In install.packages("tidyverse") :
  installation of package ‘tidyverse’ had non-zero exit status

The installation fails because I don't have the 'lattice', 'fontconfig', and 'libxml-2.0' packages. When I try to install these packages manually, R says they aren't available for my current version (3.6.3).

I'm running R 3.6.3 because the up-to-date version of R (4.x) requires a newer version of libc6 that Ubuntu doesn't support (see Installing r-base on Zorin OS (libc6 2.35 needed)). The workaround to this was to install a version of R from the cran2deb repository (cran2deb4ubuntu 4.0 : “cran2deb4ubuntu Build Team” team), which ended up being 3.6.3.

Or at least, that's my understanding? From what I can tell, my options here are to

  1. Update R to the current version. This may or may not be possible, depending on whether I messed up the installation from cran2deb the first time.
  2. Install an older and/or compatible version of the package. Probably also from cran2deb? But I think install.packages should have already been checking the cran2deb repository, and it still failed, so idk really.

Another option would be to install R from Flatpak, which will carry all dependencies with it and provide the latest version. I am aware that this carries cons as well as pros, but given what you are describing, it may be a viable course for you.

Yes, this is reasonable. For your current version lacking certain dependencies, there is another source/ option to always keep in mind.
pkgs.org

I bookmark that source on my browser. When I need to find a dependency, that is nearly the first place I always check for it. The source would be the Base of Zorin OS. For Zorin OS 16, the base is Ubuntu 20.04.

Flatpak: Is R available on flatpak? I did a search for both R and RStudio but nothing relevant came up.

Update R: Is it actually possible to do this? I thought 3.6.3 was the most up-to-date version of R available for me because of the libc6 thing, is that wrong?

Install an older version of the package: So on both pkgs.org and cran2deb, it looks like the only available tidyverse package is some variant of r-cran-tidyverse, which expects me to have R 4.0.0. Does this mean it's possible for me to install R 4.0 from cran2deb? How would I go about doing that?

You are correct.

I would not think so at a glance.
But I am not sure (if we reassemble some package dependencies it might be possible). You said that the highest you can install is 3.6.3

I looked at pckgs.org and am using:
http://archive.ubuntu.com/ubuntu/pool/universe/r/r-cran-tidyverse/r-cran-tidyverse_1.3.0-1_all.deb

Does installing that .deb offer only for R> 4.0?

My comment was based on htis:

But I have not actually checked off-hand that R is indeed available on Flathub.

Doing a net search real fast, I see:

This is actually one of several reasons I actually do not use R or Rstudio. The comments on that page cover similar issues as this thread...

Does install that .deb offer only for R> 4.0?

I'm fairly certain, yes. The cran2deb page mention R 4.0.
Trying to install it gives a bunch of dependency errors:

The following packages have unmet dependencies:
 r-cran-tidyverse : Depends: r-cran-broom but it is not going to be installed
                    Depends: r-cran-dbplyr but it is not going to be installed
                    Depends: r-cran-dplyr but it is not going to be installed
                    Depends: r-cran-dtplyr but it is not going to be installed
                    Depends: r-cran-forcats but it is not going to be installed
                    Depends: r-cran-ggplot2 but it is not going to be installed
                    Depends: r-cran-googledrive but it is not going to be installed
                    Depends: r-cran-googlesheets4 but it is not going to be installed
                    Depends: r-cran-haven but it is not going to be installed
                    Depends: r-cran-hms but it is not going to be installed
                    Depends: r-cran-modelr but it is not going to be installed
                    Depends: r-cran-readr but it is not going to be installed
                    Depends: r-cran-readxl but it is not going to be installed
                    Depends: r-cran-reprex but it is not going to be installed
                    Depends: r-cran-rvest but it is not going to be installed
                    Depends: r-cran-tibble but it is not going to be installed
                    Depends: r-cran-tidyr but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

If I try to download the packages manually, eventually I get to stuff like:

The following packages have unmet dependencies:
 r-cran-pkgconfig : Depends: r-base-core (>= 3.6.3.20200416-1.2004.0) but 3.6.3-2 is to be installed
                    Depends: r-api-4.0 but it is not installable
E: Unable to correct problems, you have held broken packages.

It's asking for a slightly more recent version of r-base-core and r-api-4.0, which is weird because apt install r-base-core tells me that r-base-core is already up to date at 3.6.3-2.

(Yeah, I'm not using R out of choice tbh, it's a requirement for a lab I joined)

Perhaps here we can find some help:
https://cran.rstudio.com/bin/linux/ubuntu/

For this line:

sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

You can replace it with:

sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/"

That did let me update to R 4.3.1, which is progress, but I'm still having some trouble getting tidyverse to install. I'll update you soon

1 Like

Ok, that solved the problem! tidyverse seems to be working for now.

After updating R from the new repository, I had to:

  1. Reinstall some R packages that were added before the update.
  2. Install tidyverse from cran2deb (Packages in “cran2deb4ubuntu 4.0” : cran2deb4ubuntu 4.0 : “cran2deb4ubuntu Build Team” team). I couldn't get tidyverse to install normally from RStudio, it complained about certain dependencies not being available for my version (as usual).
  3. Running library("tidyverse") then gave me a sort-of error message about package conflicts, but that's apparently nothing to worry about, the package will still work fine (tidyverse - Package Conflicts in R - Stack Overflow).
1 Like

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