How to fix dpkg: error: trying to overwrite 'path', which is also in package package-name in APT
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- Identify which package owns the conflicting file
- Remove the conflicting package (recommended approach)
- Fix broken packages if removal fails
- Use force-overwrite as a last resort (use cautiously)
dpkg -S /path/to/conflicting/filedpkg: 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
- 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
- Partial installation or interrupted updates leaving inconsistent package state
- 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"
First, determine which installed package already owns the file:
dpkg -S /path/to/conflicting/fileThis 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.
If the conflicting package is not essential, remove it first:
sudo dpkg -r conflicting-package-name
sudo apt update
sudo apt install desired-package-nameThis is the safest approach because it respects package dependencies and relationships. The system will handle the file ownership properly.
If you encounter dependency issues, attempt to fix broken packages:
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt updateThese commands repair inconsistent package state and may resolve underlying conflicts.
Only use this if other methods fail, as it bypasses safety checks:
For dpkg directly:
sudo dpkg -i --force-overwrite /path/to/package.debFor apt installations:
sudo apt -o Dpkg::Options::="--force-overwrite" install package-nameWarning: This approach forces installation but doesn't resolve the underlying conflict. Both packages will claim ownership of the same file, potentially causing future issues.
Clear cached packages and attempt a fresh install:
sudo apt clean
sudo apt autoclean
sudo apt update
sudo apt upgrade
sudo apt install desired-package-nameSometimes 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
- ๐APT Official Documentation
- ๐
- ๐