How to install R 3.6.3 (NOT 4+) on Linux MINT 19.x (19.1, 19.2, 19.3)

tl;dr

  • On Linux MINT 19.2, I was only able to properly install R 3.6.3 (but NOT R 4+)
  • The correct repos need to be updated in at least 2 files, only then can R be installed
  • Did I miss any tips? please leave me a comment.

Background

I have tried, and failed, to install R version 4+ on my Linux MINT 19.2. The following are the steps I took to remove my old versions of R and manage to install it again.

Some sources that helped me write this up:

  1. Ubuntu Packages For R – Brief Instructions
  2. R 3.6 for Linux Mint 19.1
  3. [SOLVED] Installing R: unmet dependencies error
  4. Problem installing R4.0 on LInux Mint 19.3
  5. Install R and RStudio on Ubuntu 22.04|20.04|18.04
  6. Linux MINT 19.x is basically Ubuntu 18.04

Step 1: remove old R + wrong repos

Open a terminal window (ctrl+alt+T) and paste (shift + insert) the following:

sudo apt purge r-base* r-recommended r-cran-*
sudo apt autoremove
sudo apt update

Once it is all removed, we should make sure we don’t have any wrongly defined repos.

For that, make sure you have gedit installed, if not, install it in the terminal using:

sudo apt-get install gedit

Once installed, we want to make sure we don’t have any wrong repos, run the following:

sudo gedit /etc/apt/sources.list.d/additional-repositories.list

And look for (and delete) lines that look like this:

deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/
deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran35/
deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/

After these are all deleted, make sure to save (hence we must use sudo before gedit), also go into the following file:

 

sudo gedit /etc/apt/sources.list

Once there make sure to remove any redundant lines from r-project. After all these lines  are gone, make sure to put in only the following line (notice the bionic-cran35 at the end):

deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/

Exit and save. Now we can install R.

Step 2: install R (+RStudio)

Open a terminal window (ctrl+alt+T) and paste (shift + insert)”

sudo apt update
sudo apt install r-base

Once this is done, open R by typing “R” in the terminal. You can then get most of the packages you might want by simply running in R:

install.packages("tidyverse")
install.packages("Rcpp")

Lastly, the simplest way to get RStudio is to go to their download page, and choose the “Ubuntu 18+/Debian 10+” option. Download and run the file.

Appendix – what could go wrong?

If for some reason you have the wrong repo (ending with 40 instead of 35), such as:

deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/

Then when trying to install R, you might get error massages such as:

The following packages have unmet dependencies:
r-base-core : Depends: libc6 (>= 2.29) but 2.27-3ubuntu1 is to be installed
Depends: libicu66 (>= 66.1-1~) but it is not installable
Depends: libreadline8 (>= 6.0) but it is not installable.

 

 

One thought on “How to install R 3.6.3 (NOT 4+) on Linux MINT 19.x (19.1, 19.2, 19.3)”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.