How to Upgrade to R 4.0.0 on Debian

This article is for you if you get the following error message:

r-base : Depends: r-recommended (= 4.0.0-1~bustercran.0) but it is not going to be installed

Woah!

R 4.0.0 is finally out!

That might sound super geeky, but that’s the first time I feel so excited for a major version of whatever technology.

I was still a kid when R 3.0.0 got out.

But nowadays, I do R every day. I eat R. I sleep R. I am R.

(Ok I’ll stop.)

This article is not here to tell you what’s new in R 4.0.0.

You can refer to this article instead:

R 4.0.0 now available

Or the official message:

R 4.0.0 is released

In this article, I want to show you how to upgrade R on Debian.

Because I struggled.

And I don’t want anyone else to struggle too.

Starting point

Pretty much all my servers use Debian. It’s stable. It just works.

But when you install R on a fresh Debian, you get R 3.5.2.

Who would want to use R 3.5.2 in 2020?

So, to install the latest version, you must:

  • Add a GnuPG key
  • Add the repo address of R

And in this article, I’ll suppose you have already done that.

That means you’re probably currently using R 3.6.3 and you want to upgrade.

But, like me, you got trouble.

If you open /etc/apt/sources.list on your server, you should see this line:

deb https://cloud.r-project.org/bin/linux/debian buster-cran35/

On this line, we can see two things:

  1. I’m using buster, which is Debian 10.
  2. And the cran35 gives me access to the latest version of R 3.x.x.

The naive solution

So if you want to update R, you simple update the repo address, then apt update, and finally apt upgrade.

Not this time.

But let’s try!

The new address is:

deb https://cloud.r-project.org/bin/linux/debian buster-cran40/

If I replace it in my /etc/apt/sources.list file, and then I do:

$ sudo apt update
$ sudo apt upgrade

A few libraries will be updated, but not R. Instead, we will get told this:

The following packages have been kept back:
  r-base r-base-core r-base-dev r-cran-boot r-cran-class r-cran-cluster r-cran-foreign
  r-cran-kernsmooth r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet
  r-cran-rpart r-cran-survival r-recommended

Why?

Because of conflicts in the dependencies.

You can try to force the install though:

$ sudo apt install r-base

Except it doesn’t work either.

You’ll get this message:

The following packages have unmet dependencies:
 r-base : Depends: r-recommended (= 4.0.0-1~bustercran.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Not cool.

So what do we do?

The good solution

In fact, everything is explained on the CRAN website.

Here: Installation instructions.

First, they give you the new repo address. That’s good. We’ve already done that.

And then they say:

Please refer to the section on bullseye above for hints on how to do the reinstallation of extension packages. Of course you need to substitute “bullseye” for “buster” if this is the distribution you are working with.

Oh.

Right.

Instead of writing sudo apt install r-base, let’s try:

apt remove r-base-core
apt install -t buster-cran40 r-base

These commands uninstall R first. And then install it again with this new parameter.

And it works!

Happy R ;)

Updated:

Comments

Craig

I am using Debian (buster) which is an app on a new Lenovo Chrombook. I am following all of these instructions but I get the message below. Do you have any ideas? No matter what I do, I can’t get a more recent version of R than 3.5.2… Thank you….

The following packages have unmet dependencies:
r-base : Depends: r-base-core (>= 4.0.3-1~bustercran.0) but 3.5.2-1 is to be installed
Depends: r-recommended (= 4.0.3-1~bustercran.0) but it is not going to be installed
Recommends: r-base-html but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Charles

Hi Craig!

You haven’t explicitely mentioned it, so have you tried the last two lines of the article? Uninstall first, then install again with the correct repo.

Also, to fully understand your situation, can you let us know: - What is displayed when you run cat /etc/issue?
- Did you uninstall all R-related apt packages?
- What happens if you try to install r-base-core directly?

In the article I provide what worked for me when I faced this issue, but I had to try many things to understand what was going on.

Boris Shor

I have the same problem with installing to a Lenovo Chromebook Duet (arm64) which is running Debian 10 - Buster. Only 3.5.2 is installed even after updating sources.list.

Jorg

My issue is slightly different: I am trying to import the public key, but receive the message “no dirmngr”. But that is a lie: dirmngr is installed and lives in the standard location.

Just another of the bugs present in the new Debian that is beginning to make me doubt its utility.

Leave a Comment

Required fields are marked *

Loading...

Comments are validated manually. The page will refresh after validation.