How to fix subprocess installed pre-removal script returned error exit status 1 in APT

APTINTERMEDIATEMEDIUMUpdated Sep 24, 2026ยท 376 views

This error occurs when a package's pre-removal script (prerm) fails during package removal or upgrade. It's typically caused by missing services, corrupted scripts, or database issues. Can usually be fixed by cleaning package cache, configuring dpkg, or forcefully removing the problematic package.

Quick fix

Fixes subprocess installed pre-removal script returned error exit status 1

sudo apt-get clean
sudo apt-get update
sudo dpkg --configure -a
  1. Clean package cache and reconfigure dpkg
  2. Fix broken packages if dpkg still fails
  3. Force remove the problematic package (last resort)
  4. Edit the pre-removal script directly (for custom packages)
apt โ€” error
sudo apt-get clean
sudo apt-get update
sudo dpkg --configure -a
subprocess installed pre-removal script returned error exit status 1

What this error means

The dpkg package manager runs pre-removal scripts (prerm) before uninstalling packages. When one of these scripts fails and exits with a non-zero status code, dpkg reports this error. This typically happens because: 1. A required service isn't running during uninstallation 2. The script was passed an unexpected argument 3. The script has corrupted or duplicate code 4. The dpkg database is corrupted 5. Trigger files are empty or damaged The error message indicates that dpkg detected a failure in the package removal process and stopped to prevent data loss.

Typical symptoms

  • Package removal fails with 'subprocess installed pre-removal script returned error exit status 1'
  • Package upgrades fail when trying to remove old versions
  • apt-get dist-upgrade or apt full-upgrade stops with this error
  • Specific package cannot be uninstalled or upgraded
  • apt-get remove or apt remove commands fail for certain packages

Common causes

  1. A required service that the pre-removal script depends on is not running during removal
  2. The pre-removal script has duplicate code or conflicting logic (common in custom DEB packages)
  3. The package's trigger files (/var/lib/dpkg/info/PACKAGE.triggers) are corrupted or empty
  4. The dpkg database or package metadata has become corrupted
  5. The pre-removal script uses 'set -e' and encounters an error without proper error handling

How to fix "subprocess installed pre-removal script returned error exit status 1"

1Clean package cache and reconfigure dpkg

Start with basic cleanup and reconfiguration commands. This fixes many corrupted package database issues:

bash
sudo apt-get clean
sudo apt-get update
sudo dpkg --configure -a

Then try removing or upgrading the package again:

bash
sudo apt-get upgrade

This approach is non-destructive and resolves the majority of pre-removal script errors. If this works, you're done.

2Fix broken packages if dpkg still fails

If dpkg reports broken dependencies after the above, use apt's fix-broken-install feature:

bash
sudo apt-get install -f
sudo apt-get upgrade

The -f flag tells apt to try to fix broken package dependencies. This resolves dependency conflicts that may be preventing the pre-removal script from running correctly.

3Force remove the problematic package (last resort)

If the package still won't budge, use dpkg's force-remove options. First identify the exact package name from the error message:

bash
sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAME

Replace PACKAGE_NAME with the actual package (e.g., mariadb-server, docker.io, etc.).

If that fails, you can move the problematic script files and try again:

bash
sudo mv /var/lib/dpkg/info/PACKAGE_NAME.prerm /tmp/
sudo mv /var/lib/dpkg/info/PACKAGE_NAME.postrm /tmp/
sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAME

Then reinstall the package if needed:

bash
sudo apt-get install PACKAGE_NAME
4Edit the pre-removal script directly (for custom packages)

If you control the package or know it's safe, you can edit the pre-removal script directly:

bash
sudo nano /var/lib/dpkg/info/PACKAGE_NAME.prerm

Either fix the script logic or replace the entire contents with a safe no-op:

bash
#!/bin/bash
exit 0

Save the file (Ctrl+O, Enter, Ctrl+X), then attempt package removal again.

5Clear dpkg locks if they exist

In rare cases, dpkg lock files may be stuck. Clear them and reconfigure:

bash
sudo rm -f /var/lib/dpkg/lock-frontend
sudo rm -f /var/lib/dpkg/lock
sudo rm -f /var/cache/apt/archives/lock
sudo dpkg --configure -a

After clearing locks, retry your apt operations.

Advanced notes

Pre-removal script failures are often package-specific. Common culprits include Docker, MariaDB, and Ubuntu Advantage Tools packages that fail to stop services cleanly.

For services like Docker, the pre-removal script tries to gracefully stop the daemon. If the daemon is already stopped or has crashed, the script fails with exit status 1. This is usually harmless and can be safely forced through.

Some packages (especially those using dh_installinit) have duplicate code between the maintainer script and the init system handler, causing conflicts. If you're maintaining a package, review your prerm script for duplicated service stop/status commands.

In containerized environments (Docker, LXC, systemd-nspawn), pre-removal scripts may fail because essential services or system tools are not available. Use force-remove options in these cases.

Always keep package metadata backups in /var/lib/dpkg/info before making manual edits to .prerm or .postrm files.

Frequently asked questions

What does "subprocess installed pre-removal script returned error exit status 1" mean?
The dpkg package manager runs pre-removal scripts (prerm) before uninstalling packages. When one of these scripts fails and exits with a non-zero status code, dpkg reports this error. This typically happens because: 1.
How do I fix "subprocess installed pre-removal script returned error exit status 1"?
This error occurs when a package's pre-removal script (prerm) fails during package removal or upgrade. It's typically caused by missing services, corrupted scripts, or database issues. Can usually be fixed by cleaning package cache, configuring dpkg, or forcefully removing the problematic package.
What causes "subprocess installed pre-removal script returned error exit status 1"?
A required service that the pre-removal script depends on is not running during removal The pre-removal script has duplicate code or conflicting logic (common in custom DEB packages) The package's trigger files (/var/lib/dpkg/info/PACKAGE.triggers) are corrupted or empty
Is the "subprocess installed pre-removal script returned error exit status 1" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading