8

I'm really struggling with installing R on Ubuntu 18. It's my first time with the OS... I tried looking up other questions here in the website and had no luck, even with this on that is basically my problem: Dependency errors while installing R in Ubuntu 17.10

Anyway, I tried running sudo apt install r-base and the response is:

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 (>= 3.4.4-1xenial0) but it is not going to be installed
          Depends: r-recommended (= 3.4.4-1xenial0) 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.

And no instruction I've seen here or in any other site seems to correct this issue... If anyone could help me I'd be so grateful! Thanks.

Suraj Rao
  • 627
Lucas X
  • 141
  • Did you upgrade from 16.04 and where those packages while being on 16.04.x ? – Videonauth May 04 '18 at 12:03
  • I didn't upgrade. I had windows on this machine and then switched to ubuntu and am learning to use it properly now... – Lucas X May 04 '18 at 12:10
  • Or did you install any PPA for r-base? None of the packages on my 18.04 have any xenial (16.04) dependencies mentioned. Or are you on 16.04? Please [edit] your question to include the output of lsb_release -a. – Videonauth May 04 '18 at 12:11
  • And you can try to use my below posted solution for a fix and tell me how it goes. – Videonauth May 04 '18 at 12:16
  • Install Ubuntu 16.04 instead. You should be able to use R reliably. Then after Ubuntu 18.04 is fixed you can upgrade. – WinEunuuchs2Unix May 04 '18 at 12:21
  • @WinEunuuchs2Unix there is nothing wrong with the r-base packages in a clean 18.04 Ubuntu installation apt-cache show "^r-base*" | grep "*xenial*" yields no output at all. And going manually over the output of apt-cache show "^r-base*" confirmed it. Those dependencies are somehow alien to an 18.04 system and im actually trying to evaluate what went wrong. – Videonauth May 04 '18 at 12:24
  • OP says there was no upgrade and it is a fresh install... – WinEunuuchs2Unix May 04 '18 at 12:28
  • Yes and i sit here in front of my main PC which is a fresh 18.04 as well :) and trying to reproduce this but i nowhere have dependencies listed for and package with xenial in the version number. Largely genuine bionic versin numbers end in 1ubuntu.. and not in 1xenial.. – Videonauth May 04 '18 at 12:29

3 Answers3

6

I found what was wrong in another post... this one: How do I restore the default repositories?
It seems some code I used from another forum just ended up messing my repositories I guess? Sorry I asked for help when I just needed to do more research :P

So what I did was:

  • run the following code: sudo rm /etc/apt/sources.list
  • then: sudo -i software-properties-gtk

Go to software-properties-gtk (run it in the console) and reset the repository to the one closest to me (geographically):

Should look like this

and then just reset the update configs to whatever suits you I guess, I put all to automatically update daily.

Then I just ran sudo apt-get intall r-base in and it worked!
Credit to the original post I mentioned earlier.

damadam
  • 2,833
Lucas X
  • 141
  • Then I will delete my answer. but I guess after cleaning up your sources.list my solution will have brought you to the proper path, so please make this a proper answer to your question :) by editing and expanding it. – Videonauth May 04 '18 at 12:33
  • Ok, but I think I don't understand what you said at the end... I should edit my answer so that I explain that you posted a answer that would have worked but I found another solution before trying yours? Sorry, I don't often user this type of forums :P don't really know the right way to do things... – Lucas X May 04 '18 at 12:39
  • No post in your answer the steps it took you to fix your system. That I was saying. Questions and answers are not only for the OP, but for people stumbling over the same mistake/problem. – Videonauth May 04 '18 at 12:41
  • 1
    -1 times infinity. DO NOT DO THIS!! These instructions are DANGEROUS and outdated. You have been warned!! – FredTheWebGuy Feb 24 '19 at 02:47
  • oh my god I already follow this to remove sources.list and it totally broke my env

    my god my god

    – JiratPasuksmit Oct 07 '19 at 12:16
0

This didn't work for me, I removed my /etc/apt/sources.list and was left with an unupdatable aws instance. I ran sudo su to get to root, then cp /etc/apt/sources.list.save /etc/apt/sources.list to replace the original as this is a default sources list with 18.04 ubuntu aws ami. I then ran sudo apt install r-base and it worked.

piie
  • 211
0

I really worked!. I uninstalled

sudo rm /etc/apt/sources.list

and followed your instructions

but before I ran

sudo apt install r-base

I made sure to add deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ (In my case I have Bionic Beaver)

The It worked, thanks!

Noblex
  • 1
  • This is a duplicate of a previous answer – damadam Dec 06 '19 at 09:03
  • @damadam This would benefit from editing, but as far as I can tell, it is the only answer so far that recommends adding deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/, so I don't think it's just a duplicate of (or "thanks" post about) any previous answer posted on this question. – Eliah Kagan Dec 06 '19 at 12:03