apt_pkg.Cache() E: Read error - read (21: is a directory)

Bug #984523 reported by cleary on 2012-04-18
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Undecided
Unassigned

Bug Description

Ubuntu Release:
12.04 precise beta 2
Description: Ubuntu precise (development branch)
Release: 12.04
Up to date as of 0100h GMT 18/4

$ apt-cache policy python-apt
python-apt:
  Installed: 0.8.3ubuntu6
  Candidate: 0.8.3ubuntu6
  Version table:
 *** 0.8.3ubuntu6 0
        500 http://gulf/au.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status

===========================
Attempting to use python-apt to manipulate a debootstrapped precise chroot - when I attempt to get a cache object from the chroot, the following error occurs:

    cache = apt_pkg.Cache(apt.progress.base.OpProgress())
SystemError: E:Read error - read (21: Is a directory), E:The package lists or status file could not be parsed or opened.

Extra testing:
* The same code functions perfectly on an 11.04 host with a debootstrapped precise chroot
* The same error appears on a 12.04 host with a debootstrapped oneric (11.10) chroot
* chrooting in with a bash shell and executing apt commands works

To replicate,
* on a precise host, debootstrap a precise or oneiric chroot
* start a python shell
>>> import apt_pkg
>>> import apt
>>> apt_pkg.init_config()
>>> apt_pkg.config.set('RootDir', '/path/to/chroot')
>>> apt_pkg.config.set('APT::Architecture', '<your chroot arch>')
>>> apt_pkg.init_system()
>>> apt_pkg.Cache(apt.progress.base.OpProgress())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: E:Read error - read (21: Is a directory), E:The package lists or status file could not be parsed or opened.
>>> apt.progress.base.OpProgress()
<apt.progress.base.OpProgress object at 0x7fba202c8b10>
>>> apt_pkg.Cache()
Reading package lists... Error!
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: E:Read error - read (21: Is a directory), E:The package lists or status file could not be parsed or opened.
>>>

cleary (bernard-gray) wrote :

This has been resolved in python-apt 0.8.3ubuntu7
It must have been related to #659438

Thanks for fixing :)

Changed in python-apt (Ubuntu):
status: New → Fix Released
cleary (bernard-gray) wrote :

Sorry, I spoke too soon - testing again on precise and this is till broken, apologies for the mucking around

Changed in python-apt (Ubuntu):
status: Fix Released → New
Julian Andres Klode (juliank) wrote :

I need more information for this, as I cannot reproduce this.

If this is still reproducible running
find /var/{lib,cache}/apt /var/lib/dpkg/status | xargs ls -ld
inside the chroot would help (or changing the absolute paths to prepend the chroot path)

because some file must be a directory

Changed in python-apt (Ubuntu):
status: New → Incomplete
cleary (bernard-gray) wrote :

I've just replicated it on a random 12.04.4 server vm
My debootstrap command:
# debootstrap precise ./chroot

Then use the python commands as listed above, and the same error appears.

I've attached the output of the find command you requested

I also took this command, grep'd on ^d to filter directories, and did a diff against the same output on a trusty host with a trusty debootstrap. They have the same directories.

========================================

This is the same python commands run on the trusty host/trusty chroot (ie, how the precise output should look):
>>> import apt_pkg
>>> import apt
>>> apt_pkg.init_config()
>>> apt_pkg.config.set('RootDir', '/media/fll/chroot/')
>>> apt_pkg.config.set('APT::Architecture', 'amd64')
>>> apt_pkg.init_system()
>>> apt_pkg.Cache(apt.progress.base.OpProgress())
<apt_pkg.Cache object at 0x7f1fe1298518>
>>>

========================================

Output from precise 12.04.4 host with precise chroot:
>>> import apt_pkg
>>> import apt
>>> apt_pkg.init_config()
>>> apt_pkg.config.set('RootDir',
... '/root/chroot/')
>>> apt_pkg.config.set('APT::Architecture', 'amd64')
>>> apt_pkg.init_system()
>>> apt_pkg.Cache(apt.progress.base.OpProgress())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: E:Read error - read (21: Is a directory), E:The package lists or status file could not be parsed or opened.
>>>

Launchpad Janitor (janitor) wrote :

[Expired for python-apt (Ubuntu) because there has been no activity for 60 days.]

Changed in python-apt (Ubuntu):
status: Incomplete → Expired
Matthias Klose (doko) on 2014-05-16
Changed in python-apt (Ubuntu):
status: Expired → New
affects: python-apt (Ubuntu) → apt (Ubuntu)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments