Score:-1

Xubuntu: "desktop-file-utils" stopped being able to be installed

us flag

After doing some package installs, the desktop-file-utils package is now failing to be installed via apt and aptitude. This is for Xubuntu 20.04.2.

When running apt, I now always get this error:

dpkg: error processing package desktop-file-utils (--configure):
 installed desktop-file-utils package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 desktop-file-utils

I know that I can purge this package, but then quite a few of its dependencies will also be uninstalled, and my system is likely to become unusable.

I don't understand what could have caused this problem, because I don't know what I could have done to affect this package.

Is there some way to fix this other than purging desktop-file-utils and making my system unusable? Also, is there some way where I can get more detailed information about exactly how the post-installation script is failing? If so, perhaps I could debug this.

Thank you in advance for any suggestions.

in flag
Are you able to `apt install --reinstall` the package?
Someone avatar
my flag
@matigo That will more likely fail. My answer explains this in detail.
Bovine avatar
ru flag
Before doing the purge, would marking the dependencies as being manually installed prevent them from being removed with the purge? `apt-mark manual pkg1 pkg2 etc`
Score:0
my flag

Let's fix this error step by step.

  1. First, run force install to know the exact problem:

    sudo apt --fix-broken install
    
  2. Identify the error:

    Errors were encountered while processing:
    desktop-file-utils
    
  3. Mark dependencies as manually installed to prevent them from getting removed;

     sudo apt-mark manual libglib2.0-0 libc6
    
  4. Remove the post-installation files:

    sudo mv /var/lib/dpkg/info/desktop-file-utils* ~/
    
  5. Purge the package:

    sudo dpkg -P --force-all desktop-file-utils
    
  6. Re-install the package (Optional):

    sudo aptitude -f install desktop-file-utils
    

Explanation

As the error message states:

installed desktop-file-utils package post-installation script subprocess returned error exit status 1

This usually implies that there are transient issues in the post-installation files.

  • In the first step, we executed a command that attempted to correct the mistakes.

  • In step three, we deleted the package's post-installation files.

  • We purged the package in step four to remove any configuration files.

  • In step five, we reinstalled the package to make sure it didn't break any other packages.

HippoMan avatar
us flag
Thank you very much. However, as I mentioned in my original post, purging the package will also uninstall numerous dependencies, and this could render my OS unusable. I am trying to see if I can fix this without purging.
HippoMan avatar
us flag
PS: Is there a different option, other than `--force-all` which will only purge the one package and not uninstall any of its dependencies?
Someone avatar
my flag
@HippoMan You can try: `dpkg -r` without force-all
Someone avatar
my flag
@HippoMan See the edit
HippoMan avatar
us flag
Oh, so are you saying that after Step 5 and before Step 6, the only package which will be uninstalled would be `desktop-file-utils` and not any of its dependencies? If so, then I see that this would indeed be a "safe" way to deal with this problem.
HippoMan avatar
us flag
Oh ... I'm sorry ... I missed step 3 in the edit. So ... I have to figure out all of the dependencies and then mark them as being manually installed; then, they won't be uninstalled during the purge. That raises the question of how to get an accurate list of dependencies, but perhaps I can figure that out.
Someone avatar
my flag
@HippoMan I've already added all the dependencies in my answer.
HippoMan avatar
us flag
In `aptitude`, a much longer list of dependencies is shown to me.
Someone avatar
my flag
@HippoMan I believe those packages are further dependencies of the listed packages. I saw that on the Official Ubuntu package search. Thus, marking the packages as manual will mark all packages as manual.
HippoMan avatar
us flag
Thank you, but in the recent past with a different package, I did a purge like this, and not only did the `official` Ubuntu dependencies get wiped out after the purge, but also, there were other dependencies that came from packages that I added from from other repos, and they got wiped out, also. I know for a fact that there are other such packages that I have added from other repos which are dependencies of `desktop-file-utils` directly. I will carefully find all of those and mark them as `manual` before I go forward with this. Thank you for all your help!
Score:-1
us flag

It turns out that this has nothing to do with packages nor with the apt system.

I discovered that I had accidentally set XDG_DATA_DIRS to point to a non-existent directory.

Once I fixed this, the problem went away.

Here are more details as to why this fixed the problem ...

These are the contents of /var/lib/dpkg/info/desktop-file-utils.postinst ...

#!/bin/sh

set -e

update-desktop-database -q

if [ "$1" = "triggered" ]; then
    exit 0
fi

I ran update-desktop-database -q from the command line, and it didn't give any output, but it exited with a non-zero return code.

I ran it again like this: update-desktop-database -v. This time, it gave an error message which stated that the applications subdirectory of the path that is contained in XDG_DATA_DIRS didn't exist. This showed me that I had set XDG_DATA_DIRS incorrectly.

Once I reset XDG_DATA_DIRS to a proper value, the update-desktop-database command started exiting with a zero return code, and the desktop-file-utils error in apt that I mentioned above stopped occurring.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.