Red Hat Customer Portal

Skip to main content

Reposync fails with traceback "UnboundLocalError: local variable 'exit_code' referenced before assignment"

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5 & 6
  • reposync

Issue

Trying to create a yum repo mirror with command reposync -p /mnt/repo --repoid=ID results in a Traceback:

[root@ mnt]# reposync -p /mnt/repo --repoid=rhel-x86_64-server-supplementary-6
Traceback (most recent call last):
  File "/usr/bin/reposync", line 352, in <module>
    main()
  File "/usr/bin/reposync", line 349, in main
    sys.exit(exit_code)
UnboundLocalError: local variable 'exit_code' referenced before assignment

abrt_version:   2.0.8
cmdline:        /usr/bin/python -tt /usr/bin/reposync -p /mnt/repo --repoid rhel-x86_64-server-supplementary-6
executable:     /usr/bin/reposync
kernel:         2.6.32-279.1.1.el6.x86_64
reason:         reposync:349:main:UnboundLocalError: local variable 'exit_code' referenced before assignment
time:           Thu 09 Aug 2012 02:39:52 PM CDT
uid:            0
username:       root

backtrace:
:reposync:349:main:UnboundLocalError: local variable 'exit_code' referenced before assignment
:
:Traceback (most recent call last):
:  File "/usr/bin/reposync", line 352, in <module>
:    main()
:  File "/usr/bin/reposync", line 349, in main
:    sys.exit(exit_code)
:UnboundLocalError: local variable 'exit_code' referenced before assignment
:
:Local variables in innermost frame:
:arches: ['ia32e', 'x86_64', 'athlon', 'i686', 'i586', 'i486', 'i386', 'noarch']
:my: <__main__.RepoSync object at 0x17e9590>
:junk: []
:opts: <Values at 0x1e28c68: {'newest': False, 'downloadcomps': False, 'quiet': False, 'destdir': '/mnt/repo', 'source': False, 'cachedir': None, 'tempcache': False, 'urls': False, 'plugins': False, 'gpgcheck': False, 'downloadmd': False, 'norepopath': False, 'config': '/etc/yum.conf', 'arch': None, 'repoid': [], 'delete': False}>

Resolution

  • Check whether proper repoid is passed along with command.

  • Pass the option -l to enable yum plugin support.

  # reposync -p /mnt/repo --repoid=ID -l

For eg:

  # reposync -p /mnt/repo --repoid=rhel-x86_64-server-supplementary-6 -l
  • If above command does not work, as a workaround downgrade yum-utils to lower version.

  • The internal bugzilla 901506 has been resolved. It has been closed with a resolution of ERRATA.
    For more information on the same follow the advisory link RHBA-2014-0138.

Root Cause

  • There is a bug with package yum-utils-1.1.30-14.el6.noarch and bugzilla 901506 was filed for this issue.

  • Can also get this error message if repoid passed with the command is not proper.

  • Check whether system is subscribed to the particular channel using following command,

  # yum repolist
  • Component
  • yum

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.