Update R in ubuntu

Viewed 987

I'm having some problems to update my R in my ubuntu. When I try I get this message:

sudo apt-get install r-base

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 r-base : Depends: r-base-core (>= 4.0.0-1.1804.0) but 3.6.3-1eoan is to be installed
          Depends: r-recommended (= 4.0.0-1.1804.0) but 3.6.3-1eoan is to be installed
E: Unable to correct problems, you have held broken packages.

When I ran: apt policy r-base i've got this message:

apt policy r-base

r-base:
  Installed: 3.6.3-1eoan
  Candidate: 4.0.0-1.1804.0
  Version table:
     4.0.0-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
 *** 3.6.3-1eoan 100
        100 /var/lib/dpkg/status
     3.6.1-4 500
        500 http://br.archive.ubuntu.com/ubuntu eoan/universe amd64 Packages
        500 http://br.archive.ubuntu.com/ubuntu eoan/universe i386 Packages

I've already changed my source list puting this inside:

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

Does anyone know what do I do to resolve this problem?

1 Answers

Browse to /etc/apt/sources.list and check if you have added the correct repo. Remove any old CRAN mirror like bionic-cran35. If you haven't properly added the current CRAN mirror, run these commands: (you can confirm the GPG key here: https://cran.r-project.org/bin/linux/ubuntu/README.html):

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/"

Then fix remaining problems and update (which might already solve the issue):

sudo apt --fix-broken install
sudo apt autoremove
sudo apt update
sudo apt upgrade

Remove current version of r and dependencies:

sudo apt remove r-base-core
sudo apt remove r-recommended
sudo apt remove r-base

Install the newest r-base:

sudo apt install r-base

To check your success, run this code:

R
version
Related