Why does uninstall leave so many remnants behind?

When installing Octave from source, I find that almost always sudo make uninstall does not cleanly undo the effects of sudo make install but leaves several directories behind in the installation directory that I need to go in and delete manually. E.g. for Octave 8 built from dev sources, there are 227 directories left behind out of 2712 files or directories as seen here after an uninstall:

list.txt (11.3 KB)

Is this because of autotools default behavior? Is there some way to undo it cleanly?

Would a change like this work or would it cause problems?

diff -r 5330efaf9476 Makefile.am
--- a/Makefile.am       Thu May 12 13:10:52 2022 -0400
+++ b/Makefile.am       Sat May 14 10:43:28 2022 -0400
@@ -482,6 +482,9 @@ uninstall-oct:
        for f in $(notdir $(OCT_FILES)); do \
          rm -f $(DESTDIR)$(octfiledir)/$$f; \
        done
+       for f in $(dir $(OCT_FILES)); do \
+         rmdir $(DESTDIR)$(octfiledir)/$$f; \
+       done
        rm -f $(DESTDIR)$(octfiledir)/PKG_ADD
 .PHONY: uninstall-oct

The above needs to be tweaked to remove all install directories in the proper sequence, from deepest to shallowest.

(Edited code to correct a typo.)

I was pretty sure this was documented behaviour in the GNU standards but I can’t find it there. Anyway, the reason is that while you know which files to remove, there may be other files in those directories that have been added since. There’s also an old thread on automake mailing list about removing empty directories by default which looks like it was ultimately “voted” down.

1 Like

I’ve always recommended configuring with something like

--prefix=/some/dir/octave/VERSION

then you can easily install multiple versions simultaneously, choose which one to use by setting your PATH appropriately, and completely remove an installed version simply by doing rm -rf /some/dir/octave/VERSION.

1 Like