command-not-found crashes when my locale is invalid

Bug #1013387 reported by Marius Gedminas
62
This bug affects 13 people
Affects Status Importance Assigned to Milestone
command-not-found
New
Undecided
Unassigned
command-not-found (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

I've these locale vars in my environment:

    $ env|grep ^LC_\\\|^LANG
    LC_MESSAGES=lt_LT.UTF-8
    LC_COLLATE=lt_LT.UTF-8
    LANG=en_US.UTF-8
    LC_CTYPE=lt_LT.UTF-8

When I ssh into a new Ubuntu 12.04 server install, that locale doesn't exist:

    $ locale charmap
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_MESSAGES to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory
    ANSI_X3.4-1968

I was trying to generate it and misspelled the command name, when suddenly command-not-found crashed:

    # localegen lt_LT.UTF-8
    Sorry, command-not-found has crashed! Please file a bug report at:
    https://bugs.launchpad.net/command-not-found/+filebug
    Please include the following information with the report:

    command-not-found version: 0.2.44

After I generated the locale, I was no longer able to reproduce the crash:

    # locale-gen lt_LT.UTF-8
    Generating locales...
      lt_LT.UTF-8... done
    Generation complete.

    # localegen lt_LT.UTF-8
    No command 'localegen' found, did you mean:
     Command 'locale-gen' from package 'locales' (main)
    localegen: command not found

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in command-not-found (Ubuntu):
status: New → Confirmed
Revision history for this message
Ma Hsiao-chun (mahsiaochun) wrote :

A reliable way to reproduce is:
$ LANG=junk junk
Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.2.3 final 0
Distributor ID: Ubuntu
Description: Ubuntu 12.10
Release: 12.10
Codename: quantal
Exception information:

unsupported locale setting
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 69, in main
    enable_i18n()
  File "/usr/lib/command-not-found", line 40, in enable_i18n
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.2/locale.py", line 541, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

Yes, probably no one would set LANG to "junk". But people may misspell locales and see the above daunting error message.

Revision history for this message
Pius (pijus-navickas) wrote :

Can't really tell anything except that I tried to use `unzip` command.
LC_PAPER=lt_LT.UTF-8
LC_ADDRESS=lt_LT.UTF-8
LC_MONETARY=lt_LT.UTF-8
LC_NUMERIC=lt_LT.UTF-8
LC_TELEPHONE=lt_LT.UTF-8
LC_IDENTIFICATION=lt_LT.UTF-8
LANG=en_GB.UTF-8
LC_MEASUREMENT=lt_LT.UTF-8
LANGUAGE=en_GB:en
LC_TIME=lt_LT.UTF-8
LC_NAME=lt_LT.UTF-8

command-not-found version: 0.3
Python version: 3.3.1 final 0
Distributor ID: Ubuntu
Description: Ubuntu 13.04
Release: 13.04
Codename: raring
Exception information:

unsupported locale setting
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 69, in main
    enable_i18n()
  File "/usr/lib/command-not-found", line 40, in enable_i18n
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.3/locale.py", line 541, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

Revision history for this message
Markus Wüstenberg (markus-o) wrote :

I have the same output on Ubuntu 13.10:

Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.3.2 final 0
Distributor ID: Ubuntu
Description: Ubuntu 13.10
Release: 13.10
Codename: saucy
Exception information:

unsupported locale setting
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 69, in main
    enable_i18n()
  File "/usr/lib/command-not-found", line 40, in enable_i18n
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.3/locale.py", line 541, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

Revision history for this message
Enderson Maia (endersonmaia) wrote :

Same error here.

:~$ whois
Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.3.2 final 0
Distributor ID: Ubuntu
Description: Ubuntu 13.10
Release: 13.10
Codename: saucy
Exception information:

unsupported locale setting
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 69, in main
    enable_i18n()
  File "/usr/lib/command-not-found", line 40, in enable_i18n
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.3/locale.py", line 541, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.