A listing of random software, tips, tweaks, hacks, and tutorials I made for Ubuntu

Easy way to fix ‘unable to open file ‘/var/lib/dpkg/’: Is a directory’

While helping a friend with his computer, I had some issues trying to install a certain .deb package, as there was this error popping up:

unable to open file '/var/lib/dpkg/': Is a directory
This is actually caused by poor packaging, where the package was generated by code in an SVN source tree. To fix it, we just have to remove all .svn directories in the package.

Run this code in a terminal (replace debfile_REPLACE_ME by the name of the broken debfile, and path/to/bad/debfile_REPLACE_ME.deb by the path to the broken debfile, including it):

sudo apt-get install dpkg-dev # Installs tools to rebuild the debian package
mkdir /tmp/deb$$
cp path/to/bad/debfile_REPLACE_ME.deb /tmp/deb$$
cd /tmp/deb$$
dpkg-deb -x debfile_REPLACE_ME.deb deb # Extracts filesystem data
cd deb
dpkg-deb -e ../debfile_REPLACE_ME.deb # Extracts metadata

Now copy the “Raw Paste Data” of this webpage to a file: I originally included the contents of this file in the post, but wordpress kept breaking it, so I had to upload it to a pastebin. Copy the file to /tmp/deb(random numbers, probably 4 of them), and rename it to ‘’ (without quotes).

Run this code in the same terminal as before:

chmod a+x ../
../ .
cd ..
sudo dpkg-deb -b deb

You can then install it using:

sudo dpkg -i deb.deb

7 responses to “Easy way to fix ‘unable to open file ‘/var/lib/dpkg/’: Is a directory’

  1. Wolve June 13, 2013 at 10:27 am

    Cool, thanks :)

  2. buffer tly October 15, 2013 at 9:24 am

    Yes, DEBIAN subdirectory must contain only the control file and pre/post install/rm scripts.

  3. ullika March 31, 2015 at 5:11 pm

    there are two things i had to change:

    after the third line you have to change directory:
    – cd /tmp/deb$$

    in the seventh command use:
    – chmod a+x ../

    thanks for providing the solution!

    • Anonymous Meerkat April 2, 2015 at 10:27 pm

      thanks for your suggestions! I’ll update the post ^^

  4. he zhenfen August 20, 2015 at 6:12 am

    thank you, but i can’t open the,is it change?

    • Anonymous Meerkat August 21, 2015 at 8:28 pm

      try running:


  5. rgb September 27, 2017 at 9:46 am

    thank you so much

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: