Apt unmet dependencies while installing R on Ubuntu 16.04
I wanted to install the new R version so I did a purge by removing all r-*. And then I broke everything unfortunately. I try to reinstall R project by typing
sudo apt install r-base r-base-core r-recommended
and then I obtain
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-core : Depends: libc6 (>= 2.27) but 2.23-0ubuntu11 is to be
installed
Depends: libcurl4 (>= 7.28.0) but it is not installable
Depends: libicu60 (>= 60.1-1~) but it is not installable
Depends: libreadline7 (>= 6.0) but it is not installable
Recommends: r-base-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Does anyone know how to solve this ?
My problem is solved.
I had put the wrong source in my sources.list to download the latest version of R. Following the instructions given in https://cloud.r-project.org/, I had put deb https://cloud.r-project.org/bin/linux/ubuntu cosmic-cran35/
instead of deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/
.
By modifying the source, everything works fine now.
So here is how to install R 3.6 on your current Ubuntu distribution, without having to manually adjust the distribution name or
sudo apt-get update
sudo apt-get install -y apt-transport-https software-properties-common
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
# this will define the DISTRIB_* environment variables
source /etc/lsb-release
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu ${DISTRIB_CODENAME}-cran35/"
# for 18.04, bionic beaver, this resolves to
#sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
# for 16.04, xenial, this resolves to
#sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/'
sudo apt-get update
sudo apt-get install -y r-base r-base-dev
R --version
Rscript --version
This should eliminate the error messages that arise from you choosing the wrong distribution like:
The following packages have unmet dependencies.
r-base-core : Depends: libc6 (>= 2.27) but 2.23-0ubuntu11 is to be
installed
Depends: libcurl4 (>= 7.28.0) but it is not installable
Depends: libicu60 (>= 60.1-1~) but it is not installable
Depends: libreadline7 (>= 6.0) but it is not installable
Recommends: r-base-dev but it is not going to be installed
Inspired by
- https://cran.r-project.org/bin/linux/ubuntu/README.html
- https://uberubuntu.info/questions/319376/wie-erhalte-ich-den-distrib-codename