Ubuntu: apt-get update: Target Packages is configured multiple times.
Oct 28, 2020
On ubuntu, while running sudo apt-get update
if you’re facing the error like this:
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-7.x.list:1 and /etc/apt/sources.list.d/elastic-7.x.list:2
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-7.x.list:1 and /etc/apt/sources.list.d/elastic-7.x.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-7.x.list:1 and /etc/apt/sources.list.d/elastic-7.x.list:2
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list.d/elastic-7.x.list:1 and /etc/apt/sources.list.d/elastic-7.x.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/elastic-7.x.list:1 and /etc/apt/sources.list.d/elastic-7.x.list:2
You just need to copy the file where the package is configured multiple times. In my case it was /etc/apt/sources.list.d/elastic-7.x.list
so I just copied and opened this file in nano with sudo permissions like this:
sudo nano /etc/apt/sources.list.d/elastic-7.x.list
It was kinda like this:
deb https://artifacts.elastic.co/packages/7.x/apt stable main
deb https://artifacts.elastic.co/packages/7.x/apt stable main
deb https://artifacts.elastic.co/packages/7.x/apt stable main
We can see there’s a line placed three times. So I just commented out the extra 2 lines and the file was looking like this:
deb https://artifacts.elastic.co/packages/7.x/apt stable main
#deb https://artifacts.elastic.co/packages/7.x/apt stable main
#deb https://artifacts.elastic.co/packages/7.x/apt stable main
Save the file and exit. Then run sudo apt-get update
and it should run smoothly.