Getting config error for yum in CentOS

7,319

Your coworker has apparently been hacking on that file. If you diff -wu it against the stock version, you get this:

--- /etc/yum.repos.d/CentOS-Base.repo   2011-12-08 20:03:29.000000000 -0700
+++ x   2012-09-06 21:24:38.244907083 -0600
@@ -1,14 +1,7 @@
-# CentOS-Base.repo
-#
-# The mirror system uses the connecting IP address of the client and the
-# update status of each mirror to pick mirrors that are updated to and
-# geographically close to the client.  You should use this for CentOS updates
-# unless you are manually picking other mirrors.
-#
-# If the mirrorlist= does not work for you, as a fall back you can try the 
-# remarked out baseurl= line instead.
-#
-#
+CentOS-Base.repo
+
+
+enabled=1

 [base]
 name=CentOS-$releasever - Base
@@ -20,7 +13,8 @@
 #released updates 
 [updates]
 name=CentOS-$releasever - Updates
-mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
+mirrorlist=http://mirrorlist.centos.org/?
+release=$releasever&arch=$basearch&repo=updates
 #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Breaking that down:

  1. Header comments removed.

    This is harmless. You do not need to replace them.

  2. Added CentOS-Base.repo line. This has to be a mistake, likely due to trying to apply step-by-step tutorial instructions from some random web site without trying to understand them first.

    Remove this line.

  3. Added enabled=1 outside of any section. According to yum.conf(5) this is illegal. Your coworker was probably trying to follow an instruction to change one of the existing enabled settings from 0 to 1.

    Remove this line, too.

  4. Broken mirrorlist line. This was probably a result of editing the file in a word processor, rather than in a plain text editor. It got word-wrapped, then saved. (This is the change most likely to have caused the actual harm.)

    Glue those two halves back together.

    Then tell your coworker that Abiword, OpenOffice.org Writer, KWord and LibreOffice Writer are not text editors. Vim, Emacs, Nano, jEdit, gedit, Kate.... these are text editors.

    With the more advanced sort of text editors, you still have to be careful you aren't turning on RTF editing or word wrapping, though, if you're going to use it for editing Linux configuration files.

Share:
7,319

Related videos on Youtube

nathpilland
Author by

nathpilland

I have a thirst for knowledge of all kinds of programming, software, and hardware of any electronic device. If you know something interesting, even if it's something novice, throw it at me.

Updated on September 18, 2022

Comments

  • nathpilland
    nathpilland almost 2 years

    I'm very new to linux, and I am using CentOS in a VM for program testing. Everything seems to be fine, except for every few minutes I get this error: Error Type: <class 'yum.Errors.ConfigError'>

    Error Value: File contains no section headers.

    I looked in a few forums, and one said to use this command cat /etc/yum.repos.d/fedora-updates.repo, but when I did so it said there was no such file or directory. Any thoughts on how I can go about fixing this?

    I'm very much a beginner when it comes to linux, so step by step would be greatly appreciated..

    EDIT:

    I used the CentOS-Base.repo command, here is the output

    CentOS-Base.repo
    
    
    enabled=1
    
    [base]
    name=CentOS-$releasever - Base
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    
    #released updates 
    [updates]
    name=CentOS-$releasever - Updates
    mirrorlist=http://mirrorlist.centos.org/?
    release=$releasever&arch=$basearch&repo=updates
    #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    
    #additional packages that may be useful
    [extras]
    name=CentOS-$releasever - Extras
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
    #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    
    #additional packages that extend functionality of existing packages
    [centosplus]
    name=CentOS-$releasever - Plus
        mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
    #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    
    #contrib - packages by Centos Users
    [contrib]
    name=CentOS-$releasever - Contrib
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
    #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    
    • Nils
      Nils almost 12 years
      Since you have got CentOS the filename will be CentOS-Base.repo. Please post the output of yum repolist.
    • Warren Young
      Warren Young almost 12 years
      Also, have you been playing with the yum configuration? Maybe enabling third-party repos in order to get packages that didn't come with CentOS? Don't make us guess.