How to fix subprocess new pre-installation script returned error exit status 127 in APT
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.
Quick fix
Fixes 127
sudo apt install --fix-broken- Try to fix broken dependencies first
- Reconfigure the dpkg database
- Identify the missing command from the error
- Install the package providing the missing command
sudo apt install --fix-brokensubprocess new pre-installation script returned error exit status 127
What this error means
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`.
Typical symptoms
- Package installation fails during the pre-installation script phase
- apt or dpkg shows 'subprocess ... returned error exit status 127'
- The error message includes 'not found' after a command name
- Cannot proceed with apt install or apt-get commands
Common causes
- A required utility or dependency is not installed on the system
- The package's pre-installation script references a command that doesn't exist
- The dpkg database is corrupted from a previous interrupted installation
- Missing packages that provide essential utilities (e.g., desktop-file-utils, libgtk2.0-bin)
- The command exists but is not in the script's PATH environment variable
How to fix "subprocess new pre-installation script returned error exit status 127"
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>Advanced notes
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.
Frequently asked questions
- What does "127" mean?
- 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.
- How do I fix "127"?
- 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.
- What causes "127"?
- A required utility or dependency is not installed on the system The package's pre-installation script references a command that doesn't exist The dpkg database is corrupted from a previous interrupted installation
- Is the "127" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.