Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an unrelated issue to this RPM issue. I'm not sure if the two relates but I'll just talk about the one that's related to running the rpm command since it's easier to explain. The other issue we're having relates to our application, which no one else would know about. ANyways, so one our QA person is trying to troubleshoot why files can't be written to this particular directory. For some reason she decided to run rpm -qa | grep -i lp. Let's say the directory is /home/tom/mydir. If she runs the rpm command outside of /home/tom/mydir as her user, she gets the desired result. If shes inside that directory, she encounters the following.

error: cannot open Packages index using db3 - Invalid argument (22)
error: cannot open Packages database in /var/lib/rpm

As root I can run the rpm command just fine within said directory or anywhere else. She thinks the issue is related, I'm just tyring to understand why this directory is giving us issue as her user.

Yes, I've tried rebuilding the RPM database as well.

share|improve this question
    
just a wild guess. Is there a chroot environment? –  Dmitri Chubarov May 25 '12 at 15:49
    
Nope, normal host. –  luckytaxi May 25 '12 at 15:49

3 Answers 3

There are few forums posts with users reporting similar issues, and the popular answer seems to being like this;

1) find and kill any process holding the rpm db open;

lsof | grep /var/lib/rpm

2) and then rebuild the db, and reboot the machine...

rm -fv /var/lib/rpm/__*
rpm --rebuilddb -v -v
sudo reboot

However, if you have already done that and had no joy, I would check the following and paste the output into your question, or into a pastebin etc...

show any aliases in effect that might be interfering with your invocation options;

$ alias                                               
alias cp='cp -i'                                                             
alias egrep='egrep --color=auto'                                             
alias fgrep='fgrep --color=auto'                                             
alias grep='grep --color=auto'                                               
alias l.='ls -d .* --color=auto'                                             
...

show the path in use (if you see a .in there, then that would explain how you might be getting the CWD effecting the command results);

$ echo $PATH
/usr/local/rvm/ge:/usr/:<snip>:/usr/local/sbin:/usr/sbin:/sbin:/opt/depot_too

Then list any executable files that might be cloaking the commands in that directory;

 ls -lh /home/tom/mydir
total 400K
drwxrwxr-x    7 tomh tomh 4.0K May 18 16:28 android
...some other stuff...

and

find /home/tom/mydir -executable

etc
fileXXX

show which executable, and which type the commands are being resolved to in both /home/tom/mydir and outside;

cd /home/tom/mydir
$ which rpm
/bin/rpm
$ type -a rpm
rpm is /bin/rpm


$ which grep
alias grep='grep --color=auto'
/bin/grep
$ type -a grep
grep is aliased to `grep --color=auto'
grep is /bin/grep
share|improve this answer
    
Thanks, last resort we would need to reboot it but we can't at this moment. Everything else you've suggested looks fine. Nothing out of the ordinary. And I have rebuilt the rpm db. The other issue she was experiencing resolved itself but I would like to know why I'm seeing the issue. –  luckytaxi May 25 '12 at 16:19
    
you can strace the rpm -qa command, or alternatively pull the source for the rpm command to see exactly what the error represents. But I would leave that to a next step after a reboot. –  Tom H May 25 '12 at 16:24

Run strace on the command in the suspect directory and again outside. It should make it clear where the issue is.

How to use strace?

share|improve this answer

Whenever I've had a command act weird in a particular directory, it has usually been one of two things: either the PATH, or the LD_LIBRARY_PATH environment variables contains relative paths, which end up picking up a binary / library from that particular directory. So, examine those two, and look for anything not beginning with a "/", and also a "::" in the middle (this will indicate to search the current directory), or a trailing ":" character.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.