Exit status 127 indicates the pre-installation script tried to run a command that doesn't exist on your system. This typically happens when a required utility is missing or not found in the PATH.
Exit status 127 is a bash 'command not found' error. When dpkg runs a package's pre-installation script, that script references a command that the system cannot locate. This could mean the command isn't installed at all, or the script's PATH environment variable doesn't include the directory where the command lives. Common missing commands include `update-desktop-database`, `gtk-update-icon-cache`, `update-info-dir`, or `systemctl`.
Run the following command to install any missing dependencies for the problematic package:
sudo apt install --fix-brokenThis attempts to resolve dependency issues that may be causing the missing commands.
Run the reconfigure command to fix the dpkg database state:
sudo dpkg --configure -aThis tells dpkg to complete any interrupted package configurations.
Look at the full error message to see which command is 'not found'. For example:
- If the error mentions update-desktop-database: not found, the command is update-desktop-database
- If it shows gtk-update-icon-cache: not found, the command is gtk-update-icon-cache
Note the exact command name for the next step.
Once you've identified the missing command, install the package that provides it. Common examples:
# For update-desktop-database
sudo apt install desktop-file-utils
# For gtk-update-icon-cache
sudo apt install libgtk2.0-bin
# For update-info-dir
sudo apt install install-info
# For systemctl
sudo apt install systemdReplace the command name with what you found in step 3.
Now that the missing dependency is installed, try to install or configure the package again:
sudo apt install <package-name>Or if it was already partially installed:
sudo apt install --fix-brokenIf the above steps don't work, completely remove the package and reinstall it:
# Completely remove the package
sudo apt remove --purge <package-name>
# Clean and update package lists
sudo apt clean
sudo apt update
# Reinstall the package
sudo apt install <package-name>If you're still unable to fix the issue after all standard steps, you can temporarily bypass the problematic pre-installation script as a last resort (not recommended for production systems): sudo mv /var/lib/dpkg/info/<package>.preinst /var/lib/dpkg/info/<package>.preinst.bad then run sudo dpkg --configure -a again. However, this may leave the package in an inconsistent state. Always try to install the missing dependencies first. In containerized or minimal environments (like Docker), some utility packages may not be included by default. Consider adding the missing packages to your base image or installation script. The error can also result from corrupted dpkg state after power failures or interrupted installations—using sudo apt install --fix-broken followed by sudo dpkg --configure -a usually resolves these cases.
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt