W: Duplicate sources.list entry [FIXED] [Ubuntu]
Okay, so ever since I upgraded to Ubuntu 14.04 through the liveCD, i hadn’t once been prompted to update stuff. This seemed unusual to me as I used to get updates every now and then, and then the fact that I hadnt upgraded from 13.04 until right after the LTS was launched and the support for Raring had already been cut off. Also, the fact that I had aborted the installation before the upgrading process had completed.
Still, after a fair amount of days had past, last night i booted it up and ran the sudo apt-get update command. It started fine but then it would get to a part where it would get stuck for several minutes and then would display several occurrences of the same error:
W: Duplicate sources.list entry http://xxxxx.xxx.xxxx xxx/xxx xx(x/x/x/x.x)
Pardon the X’s. The former part of the error is what matters. So, the first thing everyone does is a google search, and the best thread I could find on the subject was this one. I tried creating a new sources.list file after backing up the original just like it says there, and tried again. Still got the same error, so I searched again and this time I used slightly different keywords. Landed on a site that suggested checking the “other software” tab in the ‘software and updates‘ settings for duplicates. I checked and found that the “Canonical Partners” entry was recursive. I removed one and tried the old command again. And still, it didn’t make any difference.
Then I tried the “Y PPA Manager.” It actually has a tool that is supposed to search for and remove duplicates. Even that didnt work, so I decided to manually look for duplicates in the file.
The file wasn’t a pretty sight, so the first thing I did was to eradicate all those “comments.” which left me with a fine list of sources. (sudo gedit /etc/apt/sources.list) Next thing, I looked for duplicates. e.g. if there was a line that said:
deb http://xxx.xxx.xxx xxx xxx main restricted
then there shouldnt be one that says:
deb http://xxx.xxx.xxx xxx xxx restricted
since the former includes both “main” _and “_restricted.”
Since I wasn’t too sure of anything, I merely “commented” the lines that looked suspicious. (All you gotta do is add a “#” at the start of the line.) Once done disabling all possible duplicates, I saved the file and re-ran the update command. This time it worked!
However, later on i noticed that the “Canonical Partners” repo had disappeared from the list present in the “other software” tab. This I then manually added to the sources.list. Just paste the following lines:
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner