3

This question is really about the why of the error message. It would seem that duplicate entries in configuration file such as sources.list would be fairly simple to correct automatically and can be scripted fairly easily, IMHO.

According to Anwar's answer on the canonical question about this error message:

If your sources.list have a line like this

deb http://archive.ubuntu.com/ubuntu precise universe 

Then it can't have another line like the below (which your files have)

deb http://archive.ubuntu.com/ubuntu precise main universe

This seems like a fairly easy thing to resolve - split line into tokens and merge the two.

And yet, apt-get explicitly tells the user You may want to run apt-get update to correct these problems, even though in multiple posts on Ask Ubuntu the error actually appears when people do try to run apt-get update.

So is there any particular reason why apt-get doesn't resolve these automatically ? Is there some form of design concept/reasoning where it actually is desirable for this to be fixed manually ?

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • 1
    sudo apt-get check → check is a diagnostic tool; it updates the package cache and checks for broken dependencies. (man 8 apt-get). Seems apt-get has a lot options. You might to try this if it fixes the sources.list file, then it would be maybe a simple oversight in the string which gets print to stderr. Maybe in earlier times update fixed it and then it got moved? But I guess I'm only guessing around here. – Videonauth Dec 01 '17 at 21:18
  • @Videonauth well, OK that's one way to do diagnostics, but I'm more interested in why apt-get doesn't do this automatically while or before doing apt-get update ? – Sergiy Kolodyazhnyy Dec 01 '17 at 21:39
  • What if one (or more) of the duplicates was somewhere under sources.list.d? If you needed to disable the repo, then doing it in one place wouldn't work, giving unexpected results. 2) I don't know if apt is smart enough to only check the repo once and not once per entry - which would waste resources. 3) If (more like when) I screw up my sources lists, I want to figure out what I did wrong and fix it so I don't do it again. I don't want it automatically fixed - when it might be a symptom of a larger problem.
  • – Joe Dec 08 '17 at 05:27