Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dpkg: warning: while removing directory /usr/local not empty so not removed

Tags:

debian

dpkg

I built and installed a debian package from the following folder structure:

  • myprog
    • DEBIAN
      • control
    • usr
      • local
        • bin
          • myprog.sh

... using the following commands:

dpkg -b myprog/ myprog.deb && dpkg -i myprog.deb

When i now remove the package by typing:

dpkg -r myprog

.. I got the following warning:

dpkg: warning: while removing myprog, directory '/usr/local' not empty so not removed.

As I think this is an every day scenario, how can I avoid the warning?

Greets Thorsten!

# Edit

I tried to install the file to /bin instead of /usr/local/bin and got no warning when removing it. Seems so, that the /usr/local/.. folder will not treated as a system folder (?) by dpkg.

like image 256
thorsten Avatar asked Sep 13 '10 20:09

thorsten


People also ask

Why am I getting a warning when I try to remove dpkg?

In general, this warning is completely harmless and normal. When dpkg is removing (or trying to remove) a package, it removes all files and directories which were created as part of that package installation.

Why won't dpkg remove files from a folder?

This could happen either because they were machine generated, either during or after the install, or because they were created by a user. Then, unless instructed, dpkg will not remove those files. Since, by default, it will not remove a non-empty directory, in such a case, the directory containing these files will not be removed.

What happens when you remove a package from a directory?

Since, by default, it will not remove a non-empty directory, in such a case, the directory containing these files will not be removed. So, in summary, after the package is removed, you may end up with a basically empty directory (or directories) with a few machine generated files or something.

How do I clear the local repository of retrieved packages?

Other than those which you have already posted, there are few other commands which can be helpful. Autoclean clears out the local repository of retrieved package files. Also as always, you can use dpkg to install, remove and purge packages. Both dpkg and the apt-get --force-yes commands return the same error as I was getting before.


1 Answers

That's right -- packages should never touch /usr/local directory, it's reserved for system administrators by Filesystem Hierarchy Standard and is their zone of responsibility.

like image 131
Roman Cheplyaka Avatar answered Sep 19 '22 06:09

Roman Cheplyaka