Bug 974427 - dnf fails on all commands with fatal error: "global name 'os' is not defined"
dnf fails on all commands with fatal error: "global name 'os' is not defined"
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
19
i686 Linux
unspecified Severity high
: ---
: ---
Assigned To: Ales Kozumplik
Fedora Extras Quality Assurance
:
: 976002 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-14 03:47 EDT by Craig Barnes
Modified: 2014-09-30 19:41 EDT (History)
4 users (show)

See Also:
Fixed In Version: libsolv-0.3.0-5.git228d412.fc19
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-06-30 21:37:18 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Craig Barnes 2013-06-14 03:47:58 EDT
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 Craig Barnes 2013-06-14 03:53:06 EDT
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 Craig Barnes 2013-06-14 04:02:54 EDT
Adding "import os" to i18n.py seems to fix it.
Comment 3 Ales Kozumplik 2013-06-18 04:56:21 EDT
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 01:14:13 EDT
*** Bug 976002 has been marked as a duplicate of this bug. ***
Comment 5 Fedora Update System 2013-06-24 09:25:35 EDT
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 14:50:02 EDT
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-06-30 21:37:18 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.