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


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 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 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


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.



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 ;)



Leave a Comment

Required fields are marked *


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