Ubuntu – Duplicate sources.list during apt-get update

aptUbuntuubuntu-14.04update

I wanted to install PostGIS on my server which already have a PostgreSQL installed. I followed this PostGIS installation manual.

I inputted this script:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt trusty-pgdg main" >> /etc/apt/sources.list'
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -

The console echoed OK. So I proceed to updating the sources list using sudo apt-get update. That is when a warning prompt caught my attention.

W: Duplicate sources.list entry http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg/main amd64 Packages (/var/lib/apt/lists/apt.postgresql.org_pub_repos_apt_dists_trusty-pgdg_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg/main i386 Packages (/var/lib/apt/lists/apt.postgresql.org_pub_repos_apt_dists_trusty-pgdg_main_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems

I opened /etc/apt/sources.list and check for duplicate deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main but I only see one. How come it tells me there is duplicate?

Best Answer

I had the same problem. Rerunning apt-get update, as recommended in the error, simply results in the same error. Checking the contents of /etc/apt/sources.list.d/postgresql.list did show duplicates. Manually editing this file to remove duplicates fixed this error for me.