on ubuntu server 12.04, whenever I invoke a program it gives the following output

Bug #997769 reported by dude_the_rude
186
This bug affects 29 people
Affects Status Importance Assigned to Milestone
command-not-found
New
Undecided
Unassigned

Bug Description

root@mserver:~# lpstat -p
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

ALSO,

apt us archives are almost always offline when I want to update the server.

Revision history for this message
dude_the_rude (mohammed-mahfoudh) wrote :

or even when I want to install new software.

Revision history for this message
Massimo Dal Zotto (dz) wrote :

The program /usr/lib/command-not-found always crashes on a fresh installation of ubuntu-server 12.04.

It doesn't crash on ubuntu-desktop (upgraded from 11.10 to 12.04).

The crash seems related to the environment variable LC_TIME. The program crashes if LC_TIME is set to any locale except C:

### CRASHES ###
LC_TIME=it_IT.UTF-8 /usr/lib/command-not-found -- traceroute

### works ###
LC_TIME=C /usr/lib/command-not-found -- traceroute

### works ###
LC_TIME= /usr/lib/command-not-found -- traceroute

Thus the bug can be avoided adding the following code to /usr/lib/command-not-found:

try:
    import os
    del os.environ["LC_TIME"]
except:
    pass

Obviously this is only a workaround until the bug is fixed.

Revision history for this message
dude_the_rude (mohammed-mahfoudh) wrote :

Thanks a lot for taking the time to workaround this. I wonder where to put it exactly? I recognize the file is written in python but it is a long one to try to figure out while having to complete another project.

Thanks in advance.

Revision history for this message
w-sky (w-sky) wrote :

Interesting! Please, anyone may telll me:

Has there been changes in the locale environment with Ubuntu 12.04? Because I found several programs NOT working on 12.04 beta as long as the locale settings are set to something else than default, especially display of numbers and currencies etc. - not language wich is set to English.

Some of those programs always crash at start just like command-not-found, but they give some error messages when started from shell which lead me to the locale setting.

So, there seems to be a huge problem with the locale, and I am not sure if it's the best way to a solution to find all programs which now fail instead of fixing the locale thing?!?

Revision history for this message
Mike (7dlqb2n4t) wrote :

It appears the locale (or some locale files?) are missing (I started Ubuntu 12.04 LTS on Amazon EC2).

I fixed it by generating my locale:
sudo localedef -v -c -i en_US -f UTF-8 en_US.UTF-8

command-not-found could probably handle this more gracefully.

Revision history for this message
Juraj Tóth (iuryno) wrote :

Did not help me, but I stumbled on this and it is working now:
http://www.thomas-krenn.com/de/wiki/Perl_warning_Setting_locale_failed_unter_Debian

Revision history for this message
Nonox (nbulian) wrote :
Revision history for this message
Sergey Ponomarev (stokito) wrote :

I fixed it by changing one string in /usr/lib/command-not-found
Was:
 locale.setlocale(locale.LC_ALL, '')
I made
 locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

But it also just workaround

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Hey, I wrote command-not-found. No the patch from comment 8 is not valid.

The real solution is more complex. If there is anyone that wans to step up I will gladly discuss this and help them implement it. I have no time to devote to this program sadly so that's why I need someone that can help

Revision history for this message
Rene Zeldenthuis (rene-superflop) wrote :

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

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.