command-not-found crashing with incomplete locale settings

Bug #937714 reported by Martin Mrazik
38
This bug affects 7 people
Affects Status Importance Assigned to Milestone
command-not-found (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

I'm running the latest 12.04 and I'm getting the following:
---------------snip-------------
mmrazik@fry:~$ logo
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
mmrazik@fry:~$
---------------snip-------------

This is probably 2 bugs in 1:
1. the crash itself
2. the message which tells you absolutely nothing what is going on

After some debugging I realized there is something wrong with my locale setup (to be honest I don't know how I get into this state; I have a fresh install with my old home and it looks like even though I selected the en_US locale the previous CS bits stayed somewhere in home).

-------------------snip----------------
mmrazik@fry:~$ update-locale LANG=en_US.UTF-8
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = "en_US:en",
 LC_ALL = (unset),
 LC_PAPER = "cs_CZ.UTF-8",
 LC_ADDRESS = "cs_CZ.UTF-8",
 LC_MONETARY = "cs_CZ.UTF-8",
 LC_NUMERIC = "cs_CZ.UTF-8",
 LC_TELEPHONE = "cs_CZ.UTF-8",
 LC_MEASUREMENT = "cs_CZ.UTF-8",
 LC_TIME = "cs_CZ.UTF-8",
 LC_NAME = "cs_CZ.UTF-8",
 LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
update-locale: Unable to write /etc/default/locale: Permission denied
mmrazik@fry:~$
-------------------snip----------------

I found out there is no cs dir in /usr/share/locale-langpack/. After:

mmrazik@fry:~$ sudo apt-get install language-pack-cs

I'm getting:
mmrazik@fry:~$ logo
The program 'logo' is currently not installed. You can install it by typing:
sudo apt-get install ucblogo
mmrazik@fry:~$

How to reproduce:
- set your locale to a language with no language pack installed
- run command-not-found
- observe the crash

Revision history for this message
Brian Murray (brian-murray) wrote :

command-not-found should have printed some more information as seen in the following:

            print >> sys.stderr, _("command-not-found version: %s") % version
            print >> sys.stderr, _("Python version: %d.%d.%d %s %d") % sys.version_info
            try:
                import subprocess
                subprocess.call(["lsb_release", "-i", "-d", "-r", "-c"], stdout=sys.stderr)
            except (ImportError, OSError):
                pass
            print >> sys.stderr, _("Exception information:")
            print >> sys.stderr
            print >> sys.stderr, ex
            try:
                import traceback
                traceback.print_exc()
            except ImportError:
                pass

Regardless I don't think command-not-found tell people goto to +filebug but rather launch ubuntu-bug for you or just let apport catch the crash. I'll open a separate bug for that.

Changed in command-not-found (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Brian Murray (brian-murray) wrote :

How did you perform the fresh install with your old home? I'm curious if this is a problem other people might encounter.

Revision history for this message
Martin Mrazik (mrazik) wrote :

/home is a separate partition so all I did was that I wiped my root filesystem "/".

Revision history for this message
Brian Murray (brian-murray) wrote :

Right, but how did you install? Did you use the Live CD of Ubuntu 12.04 and choose to upgrade an old release of Ubuntu to 12.04 or perform a fresh install leaving your home directory alone?

Revision history for this message
Martin Mrazik (mrazik) wrote :

Sorry. Didn't understand your question.
I used LiveCD. I marked the partition with my old / to format and mount as '/' (so the old system was really completely wiped out byt the mkfs). In the same dialog I marked my home partition to mount as /home and _do not_ format.

Revision history for this message
Martin Mrazik (mrazik) wrote :

Actually.. I used the i386 liveCD of 11.10, installed 11.10 (but didn't install any 11.10 update from the internet) and only then upgraded to 12.04.

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
Scott Ritchie (scottritchie) wrote :

You can also replicate this on a very-bare install that has no language packs at all.

Revision history for this message
Daniel Kulesz (kuleszdl) wrote :

I can confirm this bug as well, I observed it on three different systems running Ubuntu 12.04. I installed each of these systems using the alternative Installer, selecting English as the System Language, German Keyboard and en_US.UTF8 for the locale (which seems to be a fix to the bug I reported here back in 2008 already: https://bugs.launchpad.net/ubuntu/+source/debian-installer/+bug/229699).

Revision history for this message
Daniel Kulesz (kuleszdl) wrote :

Update: Actually I can confirm that on systems where the "setting locale failed" problem appears also command-not-found is broken and crashes as reported by Martin here. When you get rid of the "setting locale failed" problem, command-not-found does not crash anymore.

But nevertheless, even if the locale cannot be set correctly command-not-found should not crash but give a hint to the problem like i.e. "perl" does:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "en_US:en",
        LC_ALL = (unset),
        LC_PAPER = "a4",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Revision history for this message
Jakob Unterwurzacher (jakobunt) wrote :

I also got into this state, installing 12.04.1 from the desktop CD, selecting en_US language, german keyboard, german number and date format (de_DE).

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Got this problem too, Ubuntu 12.04.1 with command-not-found 0.2.44

I found that if the chosen locale was not generated first (locale-gen), then it will cause this problem.

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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