How to fix subprocess new pre-installation script returned error exit status 127 in APT

APTINTERMEDIATEHIGHUpdated Dec 29, 2025· 137 views

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
  1. Try to fix broken dependencies first
  2. Reconfigure the dpkg database
  3. Identify the missing command from the error
  4. Install the package providing the missing command
apt — error
sudo apt install --fix-broken
subprocess 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

  1. A required utility or dependency is not installed on the system
  2. The package's pre-installation script references a command that doesn't exist
  3. The dpkg database is corrupted from a previous interrupted installation
  4. Missing packages that provide essential utilities (e.g., desktop-file-utils, libgtk2.0-bin)
  5. 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"

1Try to fix broken dependencies first

Run the following command to install any missing dependencies for the problematic package:

bash
sudo apt install --fix-broken

This attempts to resolve dependency issues that may be causing the missing commands.

2Reconfigure the dpkg database

Run the reconfigure command to fix the dpkg database state:

bash
sudo dpkg --configure -a

This tells dpkg to complete any interrupted package configurations.

3Identify the missing command from the error

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.

4Install the package providing the missing command

Once you've identified the missing command, install the package that provides it. Common examples:

bash
# 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 systemd

Replace the command name with what you found in step 3.

5Try installing the problematic package again

Now that the missing dependency is installed, try to install or configure the package again:

bash
sudo apt install <package-name>

Or if it was already partially installed:

bash
sudo apt install --fix-broken
6As a last resort, remove and reinstall the package

If the above steps don't work, completely remove the package and reinstall it:

bash
# 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.

Official resources & further reading