4

After updating R to 3.5.1 version on Ubuntu 18.04 Server I got this error message fatal error: unable to open the base package I tried to uninstall and reinstall the package three times but I still get the same error. How can I fix this?

This is the current R version on my server>>

IN: apt policy r-base

OUT: Installed: 3.5.1-1xenial
  Candidate: 3.5.1-1xenial
  Version table:
 * 3.5.1-1xenial 500
        500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages
        100 /var/lib/dpkg/status
     3.5.1-1bionic 500
        500 http://ppa.launchpad.net/marutter/rrutter3.5/ubuntu bionic/main amd64 Packages
     3.5.0-1xenial 500
        500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages

Updated

After Trying the steps from @duckmayr

this's the result of apt policy r-base

r-base:
  Installed: (none)
  Candidate: 3.5.1-1bionic
  Version table:
     3.5.1-1bionic 500
        500 http://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
     3.5.0-1bionic 500
        500 http://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
     3.4.4-1xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.4.3-1xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.4.2-2xenial2 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.4.2-1xenial1 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.4.1-2xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.4.1-1xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.4.0-1xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.3.3-1xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.3.2-1xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.3.1-1xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.3.0-2xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.3.0-1xenial0 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages
     3.2.5-1xenial 500
        500 http://cran.wustl.edu/bin/linux/ubuntu xenial/ Packages

and Get this Error when i Do sudo apt-get install r-base r-base-core

    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-recommended (= 3.5.1-1bionic) but it is not going to be installed
 r-base-core : Depends: zip but it is not installable
               Depends: unzip but it is not installable
               Depends: libpaper-utils but it is not installable
               Depends: libcurl4 (>= 7.28.0) but it is not installable
               Depends: libpango-1.0-0 (>= 1.14.0) but it is not installable
               Depends: libpangocairo-1.0-0 (>= 1.14.0) but it is not installable
               Depends: libtcl8.6 (>= 8.6.0) but it is not installable
               Depends: libtiff5 (>= 4.0.3) but it is not going to be installed
               Depends: libtk8.6 (>= 8.6.0) but it is not installable
               Recommends: r-recommended but it is not going to be installed
               Recommends: r-base-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

and Get this when trying sudo apt install libcurl4-gnutls-dev libxml2-dev libssl-dev

 Reading package lists... Done
Building dependency tree
Reading state information... Done
libcurl4-gnutls-dev is already the newest version (7.58.0-2ubuntu3.3).
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:
 libssl-dev : Depends: libssl1.0.0 (= 1.0.2g-1ubuntu4.13) but 1.0.2n-1ubuntu5.1 is to be installed
              Recommends: libssl-doc but it is not going to be installed
 libxml2-dev : Depends: libxml2 (= 2.9.3+dfsg1-1ubuntu0.6) but 2.9.4+dfsg1-6.1ubuntu1.2 is to be installed
E: Unable to correct problems, you have held broken packages.
omarahmedm93
  • 71
  • 1
  • 8
  • I see from the `apt policy` output that you have installed the Xenial package rather than the Bionic package; why is that? Did you have trouble installing the Bionic package? – duckmayr Sep 24 '18 at 14:48
  • yes, I tried to install bionic package but I faced a problem with installing R packages so I tried to install R using this commands: sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/' sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 sudo apt update. Sudo apt-get install r-base – omarahmedm93 Sep 24 '18 at 15:08
  • I will post an answer that may solve your issue; please let me know if it works or not! – duckmayr Sep 24 '18 at 15:38
  • What does `which R` return? – duckmayr Sep 24 '18 at 19:07
  • How can I remove all R version from my server, now after the last trial there are 4 R versions ( 3.5.1-1xenial 500, 3.5.1-1bionic 500, 3.5.0-1xenial 500, 3.5.0-1bionic 500 ) – omarahmedm93 Sep 25 '18 at 11:02
  • It appears that there are actually no R versions -- in `apt policy` output, a priority code of 500 means installable, and one of 100 means installed (see `man apt_preferences` or [this Unix & Linux question](https://unix.stackexchange.com/questions/121413/understanding-the-output-of-apt-cache-policy)); since none are listed as 100, it appears none are installed. This actually points me to an oversight in my answer; please see the new edits (forthcoming shortly). – duckmayr Sep 25 '18 at 11:07
  • Okay, thank you for your effort, appreciate it. – omarahmedm93 Sep 25 '18 at 11:18
  • @duckmayr I tried the steps from your answer and i updated the question after getting new errors – omarahmedm93 Sep 25 '18 at 11:54
  • @omarahmedm93 Have you deleted any system files manually? – Mümin Sep 26 '18 at 05:55
  • @Believer after removing old R using `sudo apt purge r-base` i faced the problem of installing R packages So i deleted the **libpaths** and all R directories com from `which R` – omarahmedm93 Sep 26 '18 at 12:11

1 Answers1

4

It appears you have a Xenial (Ubuntu 16.04) package for R 3.5.1 installed, so it may fix your issue to get the Bionic (Ubuntu 18.04) version installed. I have an answer here demonstrating upgrading to R 3.5.x on Linux Mint 19, and as I explain here, the instructions work just as well for Ubuntu 18.04 (since Mint is Ubuntu-based); I have some machines running Mint 19 and some running Ubuntu 18.04, and I use the same process for both. However, this seems not quite to be a duplicate as you have some cleanup to do before following the correct install process, and some of the steps you can skip. This is what I would do:

1. Remove your current R installation

You can do this via

sudo apt purge r-base

Or, if you also have r-base-dev

sudo apt purge r-base r-base-dev

2. Remove erroneous repositories

You have added the following repositories:

  1. ppa:marutter/rrutter3.5
  2. https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/

You should be able to remove them via

sudo apt-add-repository --remove ppa:marutter/rrutter3.5
sudo apt-add-repository --remove 'deb cloud.r-project.org/bin/linux/ubuntu xenial-cran35/'

3. Install the Bionic package for R 3.5.1

This follows my guide linked above, but skips the step of adding the trusted key, since you've already done that; you should be OK if you run the following:

sudo echo "deb http://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install r-base r-base-dev

Note also that I have put to install r-base and r-base-dev, but I don't know if you want r-base-dev. I highly recommend it.

Then, you should be able to get a fresh R session going, where you can run

update.packages(checkBuilt = TRUE, ask = FALSE)

to make sure you have all your previously installed R packages.

duckmayr
  • 16,303
  • 3
  • 35
  • 53