How to fix dpkg: error: trying to overwrite 'path', which is also in package package-name in APT

APTINTERMEDIATEHIGHUpdated Dec 29, 2025ยท 483 views

This error occurs when two different packages contain the same file, preventing installation. Resolve it by removing conflicting packages, using force options carefully, or fixing the underlying package conflict.

Quick fix

Fixes dpkg: error: trying to overwrite 'path', which is also in package package-name

dpkg -S /path/to/conflicting/file
  1. Identify which package owns the conflicting file
  2. Remove the conflicting package (recommended approach)
  3. Fix broken packages if removal fails
  4. Use force-overwrite as a last resort (use cautiously)
apt โ€” error
dpkg -S /path/to/conflicting/file
dpkg: error: trying to overwrite 'path', which is also in package package-name

What this error means

The dpkg (Debian Package Manager) error "trying to overwrite X, which is also in package Y" happens when you attempt to install a package that contains a file that's already owned by another installed package. In Debian/Ubuntu systems, each file should be owned by exactly one package. This conflict typically arises when package maintainers split or reorganize files between packages without properly declaring package relationships, or when installing packages from different sources that overlap in provided files.

Typical symptoms

  • Installation fails with dpkg error message mentioning file conflicts
  • apt update or apt upgrade fails before reaching completion
  • Package manager shows conflicting files preventing package installation
  • System cannot install newer versions of packages due to file overlaps

Common causes

  1. Package maintainers split architecture-independent files into separate packages without declaring Replaces relationship
  2. Installing packages from different sources (PPAs, third-party repos) that provide overlapping files
  3. Attempting to downgrade or switch between conflicting package versions
  4. Partial installation or interrupted updates leaving inconsistent package state
  5. Custom or manually installed packages conflicting with system packages

How to fix "dpkg: error: trying to overwrite 'path', which is also in package package-name"

1Identify which package owns the conflicting file

First, determine which installed package already owns the file:

bash
dpkg -S /path/to/conflicting/file

This will show you the package that currently owns the file. This information helps you decide which package to remove or which conflict resolution approach to take.

2Remove the conflicting package (recommended approach)

If the conflicting package is not essential, remove it first:

bash
sudo dpkg -r conflicting-package-name
sudo apt update
sudo apt install desired-package-name

This is the safest approach because it respects package dependencies and relationships. The system will handle the file ownership properly.

3Fix broken packages if removal fails

If you encounter dependency issues, attempt to fix broken packages:

bash
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt update

These commands repair inconsistent package state and may resolve underlying conflicts.

4Use force-overwrite as a last resort (use cautiously)

Only use this if other methods fail, as it bypasses safety checks:

For dpkg directly:

bash
sudo dpkg -i --force-overwrite /path/to/package.deb

For apt installations:

bash
sudo apt -o Dpkg::Options::="--force-overwrite" install package-name

Warning: This approach forces installation but doesn't resolve the underlying conflict. Both packages will claim ownership of the same file, potentially causing future issues.

5Clean package cache and retry installation

Clear cached packages and attempt a fresh install:

bash
sudo apt clean
sudo apt autoclean
sudo apt update
sudo apt upgrade
sudo apt install desired-package-name

Sometimes corrupted cache files cause false conflicts. Cleaning the cache resolves these cases.

Advanced notes

When package maintainers properly declare package relationships using the "Replaces" field in package metadata, dpkg allows controlled file transfers between packages. However, this requires coordination between package maintainers. If you encounter this error frequently, it may indicate issues with your package sources or repositories. Consider verifying your /etc/apt/sources.list configuration and removing PPAs that conflict with official repositories. For system stability, always prefer removing conflicting packages over forcing overwrites.

Frequently asked questions

What does "dpkg: error: trying to overwrite 'path', which is also in package pack" mean?
The dpkg (Debian Package Manager) error "trying to overwrite X, which is also in package Y" happens when you attempt to install a package that contains a file that's already owned by another installed package. In Debian/Ubuntu systems, each file should be owned by exactly one package. This conflict typically arises when package maintainers split or reorganize files between packages without properly declaring package relationships, or when installing packages from different sources that overlap in provided files.
How do I fix "dpkg: error: trying to overwrite 'path', which is also in package pack"?
This error occurs when two different packages contain the same file, preventing installation. Resolve it by removing conflicting packages, using force options carefully, or fixing the underlying package conflict.
What causes "dpkg: error: trying to overwrite 'path', which is also in package pack"?
Package maintainers split architecture-independent files into separate packages without declaring Replaces relationship Installing packages from different sources (PPAs, third-party repos) that provide overlapping files Attempting to downgrade or switch between conflicting package versions
Is the "dpkg: error: trying to overwrite 'path', which is also in package pack" 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