Fix removing packages that were installed from a tarball

Fixes #898.