Bug 402597

Summary: Zypp cannot read solv file
Product: [openSUSE] openSUSE 11.0 Reporter: Lubos Lunak <llunak>
Component: libzyppAssignee: Michael Schröder <mls>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P2 - High CC: dmacvicar, francis, geoff, ma, psychonaut, werner
Version: Final   
Target Milestone: ---   
Hardware: x86   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: zypper.log.gz

Description Lubos Lunak 2008-06-22 20:33:49 UTC
New instalation of 11.0 (with few modifications, but none should be relevant for this). Installation itself went fine, after trying to add community repositories I'm unable to use zypper or 'yast2 -i' for anything. The error is "Error reading solv-file: /var/cache/zypp/solv/openSUSE-11.0-Updates/solv" or similar.

I could already reproduce it on another machine before, but there 'zypper clean -m' and 'zypper refresh' avoided the problem. However here, no matter what I try, it appears the system is unable to create the caches. I even tried copying /var/cache/zypp from another machine, that works fine until things need to be refreshed. Even things like removing all repositories, or even wiping out /var/cache/zypp don't help.

Attached is /var/log/zypper.log for the following sequence:

$ zypper lr
No repositories defined. Use the 'zypper addrepo' command to add one or more repositories.

$ zypper ar http://download.opensuse.org/distribution/11.0/repo/oss 'OSS'
Adding repository 'OSS' [done]
Repository 'OSS' successfully added
Enabled: Yes
Autorefresh: No
URI: http://download.opensuse.org/distribution/11.0/repo/oss

$ zypper search blahblah
Building repository 'OSS' cache [done]
Building repository 'OSS' cache [done]
Problem loading data from 'OSS'
Error reading solv-file: /var/cache/zypp/solv/OSS/solv
Try 'zypper refresh', or even 'zypper clean -m' before doing so.
Resolvables from 'OSS' not loaded because of error.
Reading installed packages...
No resolvables found.

(Yes, it looks like it tries to build the cache twice, but it doesn't always do that. It doesn't work in either case though.)
Comment 1 Lubos Lunak 2008-06-22 20:34:59 UTC
Created attachment 223627 [details]
zypper.log.gz
Comment 2 Lubos Lunak 2008-06-23 14:18:32 UTC
It is caused by having $CDPATH set (mine is 'CDPATH=.:/media:/mnt:/usr/share:/usr:/home'). The solv file is generated by redirecting output of the repo2solv.sh script and the script apparently does cd somewhere, which gets written at the beginning of the file (specifically, the path is e.g. /var/cache/zypp/raw/repo-oss/suse/setup/descr). I suggest 'unset CDPATH' at the beginning of repo2solv.sh (or beating hard whoever invented this cd+CDPATH misfeature).
Comment 3 Tristan Miller 2008-06-23 21:14:34 UTC
*** Bug 402811 has been marked as a duplicate of this bug. ***
Comment 4 Tristan Miller 2008-06-23 21:16:10 UTC
I happen to find Bash's CDPATH function quite useful, Lubos.  The bug here lies with repo2solv.sh, not Bash.
Comment 5 Michael Schröder 2008-06-24 12:32:41 UTC
(Maybe, but the shell shouldn't print the cdpath to stdout if it's not in interactive mode.)
Comment 6 Michael Andres 2008-07-09 11:19:14 UTC
Looks like the 'unset CDPATH' workaround is implemented in satsolver. 

@Werner: IMO comment #5 is valid. 
Comment 7 Michael Schröder 2008-07-09 12:28:06 UTC
It's fixed in svn, but we still need to submit a package plus make a maintenance update.
Comment 9 Anja Stock 2008-08-12 12:26:50 UTC
released
Comment 10 Geoff Kuenning 2008-08-15 00:58:27 UTC
I'll expand on comment #5: bash shouldn't EVER print the directory to stdout, even in interactive mode.  It should go to stderr.  (And in non-interactive mode, as Michael points out, it should be silent.  Actually, I think that the correct behavior might be to ignore CDPATH in non-interactive mode; doing otherwise is a potential security hole.)

I couldn't find a bash bug open on this issue.  Perhaps somebody should open one?
Comment 11 Dr. Werner Fink 2008-08-15 09:05:02 UTC
To be noted: if you think this is a bash bug please report it upstream.
I'll not change common behaviour of the bash.  There is no point in the
current manual page which states that CDPATH is for interactive usage
only.  Beside this normaly CDPATH is empty.
Comment 12 Geoff Kuenning 2008-08-15 09:31:39 UTC
Oh, fine, Werner.  Kick me in the butt and make me do what I should have done in the first place. :-D

I've reported it as a bash bug.
Comment 13 Dr. Werner Fink 2008-08-15 09:54:22 UTC
;) 
Maybe there are some more variables which are normaly used in
interactive mode but also available in script mode.  The question
rises how many scripts are out there relying on such variables
like CDPATH and others:

     #!/bin/bash 
     CDPATH=/tmp
     tmp=$(mktemp -d ${CDPATH}/${0##*/}.XXXXXX) || exit 1
     wrk=${tmp##*/}
     cd $wrk



Comment 14 Geoff Kuenning 2008-08-15 10:37:44 UTC
Good point.  I've taken the liberty of filing a second bash bug report with your comments included, and basically saying that the bash developers need to audit bash.  My suggestion to them is that bash should null out all such variables at the top, and then let scripts set them if they choose.
Comment 15 Tristan Miller 2008-08-15 10:58:26 UTC
Can you please provide links to the bash bug reports?  (I'm assuming they use some sort of online bug tracker rather than a mailing list.)
Comment 16 Geoff Kuenning 2008-08-15 22:41:15 UTC
Bash's bug-reporting system is a script named "bashbug", which sends mail to their list.  I suppose they have an online tracker but I don't know where it is.

They've responded (by e-mail) to my reports.  The first response says, in essence, "That's the way the POSIX standard says CDPATH should behave."  The second says, in essence, "all variables are documented and it's the script-writers problem to deal with it."  He also pointed out that modifying bash to start unsetting dangerous variables is risky from a backwards-compatibility standpoint (which I think is a fair point).  Finally, he mentioned that the CDPATH issue has been reported multiple times.  I'd take that letter comment as a sign of a big design error, but that's going to be a hard sell.

I'm going to reply, pointing out that the POSIX standard is (a) ambiguous about whether CDPATH needs to be reported for non-interactive shells, and (b) wrong for asking it to be reported to stdout.  But I doubt I'll win the argument.

So I think we're stuck with it.  Something I came across pointed out that you can always write "cd ./foo" instead of "cd foo", but that's hardly more convenient that simply unsetting CDPATH.
Comment 17 Michael Schröder 2008-08-21 17:12:59 UTC
(Reassigned to werner as the update is released and this is about bash...)
Comment 18 Dr. Werner Fink 2008-09-01 10:45:54 UTC
As already told (see I comment #11)  will not change the common behaviour
of the bash. This should happen upstream only.
Comment 19 Michael Schröder 2008-09-01 17:13:54 UTC
Ok, closing (as a fixed libzypp is already avaiable, see #9)