Yum – Warning – “Repository packages-microsoft-com-prod is listed more than once in the configuration”

Background

There is a bit of an annoying error that I get whenever I issue yum commands against my Linux CentOS host.

Error

The error reads :-

Image

error.01.20190915.0201PM

Textual


Repository packages-microsoft-com-prod is listed more than once in the configuration

Troubleshooting

Yum Repository

/etc/yum.repos.d

Objective

Let us look into our /etc/yum.repos.d folder and see which files reference packages-microsoft-com-prod

Command

Syntax

grep -r [repository] /etc/yum.repos.d

Sample

grep -r packages-microsoft-com-prod /etc/yum.repos.d

Output
Output – Image

grep.microsoft.01.20190915.0858AM.PNG

Output – Text

grep -r packages-microsoft-com-prod /etc/yum.repos.d

/etc/yum.repos.d/microsoft.repo:[packages-microsoft-com-prod]
/etc/yum.repos.d/microsoft.repo:name=packages-microsoft-com-prod

/etc/yum.repos.d/msprod.repo:[packages-microsoft-com-prod]
/etc/yum.repos.d/msprod.repo:name=packages-microsoft-com-prod

/etc/yum.repos.d/mssql-release.repo:[packages-microsoft-com-prod]
/etc/yum.repos.d/mssql-release.repo:name=packages-microsoft-com-prod

Explanation

The following files reference packages-microsoft-com-prod

  1. /etc/yum.repos.d/microsoft.repo
  2. /etc/yum.repos.d/msprod.repo
  3. /etc/yum.repos.d/mssql-release.repo

Why so many files

Google to the Rescue

1) microsoft.repo

Googled on microsoft.repo and ended up here :-

Docs > PowerShell > Scripting
Installing PowerShell Core on Linux
Link

The relevant curl command reads :-

# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

If one downloads https://packages.microsoft.com/config/rhel/7/prod.repo, it will read

[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/rhel/7/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

We see that issuing curl and capturing its output via tee, creates a new file, microsoft.repo.

The targeted repository is packages-microsoft-com-prod.

2) msprod.repo

Googled on msprod.repo and ended up here :-

Docs > SQL > SQL Server on Linux > Concepts > Install  >Install SQL Server tools
Install sqlcmd and bcp the SQL Server command-line tools on Linux
Link

The relevant command reads :-

curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo

If one downloads https://packages.microsoft.com/config/rhel/7/prod.repo, it will read

[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/rhel/7/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

We see that issuing curl creates a new file, msprod.repo, but the repository is packages-microsoft-com-prod.

3) mssql-release.repo

Googled on mssql-release.repo and ended up here :-

Docs > SQL > SQL Server on Linux > Concepts > Install > Configure repositories
Configure repositories for installing and upgrading SQL Server on Linux
Link

The relevant command reads :-

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-preview.repo

If one downloads https://packages.microsoft.com/config/rhel/7/prod.repo, it will read

[packages-microsoft-com-mssql-server-preview]
name=packages-microsoft-com-mssql-server-preview
baseurl=https://packages.microsoft.com/rhel/7/mssql-server-preview/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

We see that issuing curl creates a new file, mssql-server.repo, and the repository is packages-microsoft-com-mssql-server-preview.

Remediation

Sourcing

Here is how we got our various repo files

  1. File :- /etc/yum.repos.d/microsoft.repo
    • Source :- Installing Powershell
    • Repository :- packages-microsoft-com-prod
  2. /etc/yum.repos.d/msprod.repo
    • Source :- Installing Microsoft SQL Server v2017
    • Repository :- packages-microsoft-com-prod
  3. /etc/yum.repos.d/mssql-server.repo
    • Source :- Upgrading Microsoft SQL Server from v2017 to v2019
    • Repository :- packages-microsoft-com-mssql-server-preview

Duplicates

The duplicate files in our case are /etc/yum.repos.d/microsoft.repo and /etc/yum.repos.d/msprod.repo.

Remove

Decision

We will remove /etc/yum.repos.d/msprod.repo

Syntax


sudo rm /etc/yum.repos.d/[file].repo

Sample


sudo rm /etc/yum.repos.d/msprod.repo

Review

Outline

Here are some tools one can use to go see if things are well.

  1. yum repolist
  2. yum check

Tasks

yum repolist

Sample


yum repolist all | grep microsoft

Output

yum.repolist.all.packages-microsoft-com-prod.01.20190915.0617PM

Explanation

  1. Once we removed the duplicate repository file, we are left with the following repositories
    • package-microsoft-com-mssql-server-preview
    • packages-microsoft-com-prod

yum check

Sample


yum check all

Output

yum.check.all.packages-microsoft-com-prod.01.20190915.0532PM

Sample – Time


time yum check all

Output

yum.check.all.time.packages-microsoft-com-prod.01.20190915.0600PM.PNG

Explanation

  1. Issuing, yum check all, took about 12 1/2 minutes on my host.

Summary

Another beginner mistake.

Created duplicated repo files.

The fact that they are pointing at the same repository is causing a bit of havoc.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s