Typing an unknown command in a deleted directory makes command-not-found angry

Bug #118814 reported by Ryan Cumming
16
Affects Status Importance Assigned to Milestone
command-not-found
Invalid
Undecided
Unassigned
db4.4 (Debian)
Fix Released
Unknown
db4.4 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Shell 1:
mkdir foo
cd foo

Shell 2:
rm -Rf foo

Shell 1:
sfghjsghjsfgh

Produces:
Unable to open binary database %s: %s /usr/share/command-not-found/programs.d/i386-multiverse.db (2, 'No such file or directory')
Unable to open binary database %s: %s /usr/share/command-not-found/programs.d/i386-main.db (2, 'No such file or directory')
Unable to open binary database %s: %s /usr/share/command-not-found/programs.d/i386-restricted.db (2, 'No such file or directory')
Unable to open binary database %s: %s /usr/share/command-not-found/programs.d/all-multiverse.db (2, 'No such file or directory')
Unable to open binary database %s: %s /usr/share/command-not-found/programs.d/all-main.db (2, 'No such file or directory')
Unable to open binary database %s: %s /usr/share/command-not-found/programs.d/i386-universe.db (2, 'No such file or directory')
Unable to open binary database %s: %s /usr/share/command-not-found/programs.d/all-restricted.db (2, 'No such file or directory')
Unable to open binary database %s: %s /usr/share/command-not-found/programs.d/all-universe.db (2, 'No such file or directory')
bash: sfghjsghjsfgh: command not found

Revision history for this message
Dominic Chen (ddcc) wrote :

Occurs for me too on Feisty 7.04. Encountered this error when trying to run alsa-oss teamspeak in a deleted directory.

Revision history for this message
Nicolai P (nicolaip) wrote :

I can confirm this bug. You can also see this with one terminal open; mkdir cnf; cd cnf; rm -rf ../cnf; thisDoesNotExist;

Changed in command-not-found:
status: New → Confirmed
Revision history for this message
Jason Ribeiro (jrib) wrote :

There's a typo in the way the actual error message is being printed which I fixed here: sftp://<email address hidden>/~jrib/command-not-found/ubuntu.bug118814 .

Why the error is actually showing up isn't really command-not-found-specific. If you try this, you see you get an error too:

# works fine
+(jrib@luso:~)
% python -c "import dbm; dbm.open('/usr/share/command-not-found/programs.d/all-universe', 'r');"

# does not work fine in non-existant directory
 +(jrib@luso:~)
% mkdir foo; cd foo; rmdir ../foo; python -c "import dbm; dbm.open('/usr/share/command-not-found/programs.d/all-universe', 'r');"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
dbm.error: (2, 'No such file or directory')

Revision history for this message
Jason Ribeiro (jrib) wrote :

Similarly, same thing happens with things like db4.4_stat:

+(jrib@luso:~)
% db4.4_stat -d /usr/share/command-not-found/programs.d/all-universe.db
Thu Aug 9 18:59:44 2007 Local time
61561 Hash magic number
8 Hash version number
Little-endian Byte order
        Flags
4096 Underlying database page size
40 Specified fill factor
2774 Number of keys in the database
2774 Number of data items in the database
128 Number of hash buckets
446917 Number of bytes free on bucket pages (14% ff)
0 Number of overflow pages
0 Number of bytes free in overflow pages (0% ff)
0 Number of bucket overflow pages
0 Number of bytes free in bucket overflow pages (0% ff)
0 Number of duplicate pages
0 Number of bytes free in duplicate pages (0% ff)
0 Number of pages on the free list
+(jrib@luso:~)
% mkdir foo; cd foo; rmdir ../foo; db4.4_stat -d /usr/share/command-not-found/programs.d/all-universe.db
db4.4_stat: no absolute path for the current directory: No such file or directory
db4.4_stat: no absolute path for the current directory: No such file or directory
db4.4_stat: DB_ENV->open: No such file or directory

Revision history for this message
Jason Ribeiro (jrib) wrote :

I decided to try db4.5_stat as well... It turn out this one works fine on non-existant directories.

% ldd /usr/lib/python2.5/lib-dynload/dbm.so (20:22/10322)
        linux-gate.so.1 => (0xffffe000)
        libdb-4.4.so => /usr/lib/libdb-4.4.so (0xb7e14000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7dfd000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7cbb000)
        /lib/ld-linux.so.2 (0x80000000)

suggests the dbm module in python is using libdb4.4 and this problem might just go away once the dbm module uses a later version of libdb but I admit I don't much about the policies behind that.

Revision history for this message
Jason Ribeiro (jrib) wrote :

debian bug #388835 seems to be the same.

I'm going to open a new bug about the typo with the way the error message is being printed and this bug I'm going to reassign to db4.4

Jason Ribeiro (jrib)
Changed in command-not-found:
status: New → Invalid
Changed in db4.4:
status: Unknown → New
Revision history for this message
Steve Illgen (sillgen) wrote :

I get this message in Gutsy Gibbon after typing the an unknown command (in this case, 'll') even after removing and reinstalling the package. This did not happen until I did a basic upgrade on 27 Aug 07:

KABOOOM!!!

Whoops, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/ubuntu/+source/command-not-found
Please include the following information with the report:
[Errno 2] No such file or directory: '/usr/share/command-not-found/programs.d'
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 24, in <module>
    CommandNotFound(options.data_dir).advise(args[0])
  File "/usr/lib/python2.5/site-packages/CommandNotFound/CommandNotFound.py", line 72, in __init__
    for filename in os.listdir(os.path.sep.join([data_dir, self.programs_dir])):
OSError: [Errno 2] No such file or directory: '/usr/share/command-not-found/programs.d'
Python version: 2.5.1 final 0
bash: ll: command not found

Revision history for this message
Jason Alexandre Ribeiro (jason-ribeiro) wrote : Re: [Bug 118814] Re: Typing an unknown command in a deleted directory makes command-not-found angry

On 8/28/07, Steve Illgen <email address hidden> wrote:
> I get this message in Gutsy Gibbon after typing the an unknown command
> (in this case, 'll') even after removing and reinstalling the package.
> This did not happen until I did a basic upgrade on 27 Aug 07:
Hey Steve,

Your error seems to be different than the one reported here. The
error reported here occurs when command-not-found is used and the
current working directory no longer exists. Your should open a new
bug for your error if it is still occurring.

Changed in db4.4 (Debian):
status: New → Fix Released
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.