Bug 974427

Summary: dnf fails on all commands with fatal error: "global name 'os' is not defined"
Product: [Fedora] Fedora Reporter: craigbarnes85
Component: dnfAssignee: Ales Kozumplik <akozumpl>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 19CC: akozumpl, jzeleny, pnemade, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: libsolv-0.3.0-5.git228d412.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-01 01:37:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description craigbarnes85 2013-06-14 07:47:58 UTC
Since the most recent set of updates on Fedora 19, dnf errors out and produces the following backtrace for every command I try:

  $ sudo dnf update
  Failed to set locale, defaulting to C
  Traceback (most recent call last):
    File "/bin/dnf", line 35, in <module>
      main.user_main(sys.argv[1:], exit_code=True)
    File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 304, in user_$
      errcode = main(args)
    File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 39, in main
      _main(base, args)
    File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 44, in _main
      dnf.i18n.setup_locale()
    File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 53, in setup_loca$
      os.environ['LC_ALL'] = 'C'
  NameError: global name 'os' is not defineded

Using the following versions:

  $ rpm -q hawkey libsolv dnf python
  hawkey-0.3.13-2.git15db39f.fc19.i686
  libsolv-0.3.0-3.git7399ad1.fc19.i686
  dnf-0.3.7-1.gitf8bdc98.fc19.noarch
  python-2.7.5-1.fc19.i686

I'm not too familiar with Python, but the backtrace seems to suggest that it's related to locale settings. My /etc/locale.conf was originally set manually to:

  LANG=en_GB.utf8

I tried setting it via GNOME control panel to see if it made any difference but it came up with the same error and the following /etc/locale.conf:

  LANG=en_GB.utf8
  LC_NUMERIC=en_GB.UTF-8
  LC_TIME=en_GB.UTF-8
  LC_MONETARY=en_GB.UTF-8
  LC_PAPER=en_GB.UTF-8
  LC_MEASUREMENT=en_GB.UTF-8

Any debugging help from someone more knowledgeable about Python/dnf would be appreciated.

Comment 1 craigbarnes85 2013-06-14 07:53:06 UTC
Sorry, that backtrace got mangled by my editor. It was supposed to be:

$ sudo dnf update
Failed to set locale, defaulting to C
Traceback (most recent call last):
  File "/bin/dnf", line 35, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 304, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 39, in main
    _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 44, in _main
    dnf.i18n.setup_locale()
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 53, in setup_locale
    os.environ['LC_ALL'] = 'C'
NameError: global name 'os' is not defined

Comment 2 craigbarnes85 2013-06-14 08:02:54 UTC
Adding "import os" to i18n.py seems to fix it.

Comment 3 Ales Kozumplik 2013-06-18 08:56:21 UTC
This is triggered each time python fails to set the locale (perhaps because the respective locale files are not present on the system). importing the 'os' module indeed fixes this for the fallback scenario.

Fixed by e11d928, this will be included with dnf-0.3.8.

Comment 4 Panu Matilainen 2013-06-20 05:14:13 UTC
*** Bug 976002 has been marked as a duplicate of this bug. ***

Comment 5 Fedora Update System 2013-06-24 13:25:35 UTC
libsolv-0.3.0-5.git228d412.fc19, librepo-0.0.4-2.fc19, hawkey-0.3.14-1.git78b3aa0.fc19, dnf-0.3.8-2.git85524ae.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/libsolv-0.3.0-5.git228d412.fc19,dnf-0.3.8-2.git85524ae.fc19,hawkey-0.3.14-1.git78b3aa0.fc19,librepo-0.0.4-2.fc19

Comment 6 Fedora Update System 2013-06-24 18:50:02 UTC
Package libsolv-0.3.0-5.git228d412.fc19, librepo-0.0.4-2.fc19, hawkey-0.3.14-1.git78b3aa0.fc19, dnf-0.3.8-2.git85524ae.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing libsolv-0.3.0-5.git228d412.fc19 librepo-0.0.4-2.fc19 hawkey-0.3.14-1.git78b3aa0.fc19 dnf-0.3.8-2.git85524ae.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-11602/libsolv-0.3.0-5.git228d412.fc19,dnf-0.3.8-2.git85524ae.fc19,hawkey-0.3.14-1.git78b3aa0.fc19,librepo-0.0.4-2.fc19
then log in and leave karma (feedback).

Comment 7 Fedora Update System 2013-07-01 01:37:18 UTC
libsolv-0.3.0-5.git228d412.fc19, librepo-0.0.4-2.fc19, hawkey-0.3.14-1.git78b3aa0.fc19, dnf-0.3.8-2.git85524ae.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.