The "Conflicts: package-name but version is to be installed" error occurs when apt detects conflicting package dependencies. This guide covers identifying the conflict, resolving dependency mismatches, and fixing broken package states to successfully complete your installation or upgrade.
When you run apt install or apt upgrade, the package manager checks for conflicts between packages and their dependencies. This error indicates that a package being installed or upgraded conflicts with another package already installed on your system, or with the specific version that apt is trying to install. The conflict is typically caused by incompatible versions of packages that both depend on conflicting libraries or functionality. APT's dependency resolver identifies this conflict and prevents installation to avoid breaking your system.
Start by refreshing your package lists and checking for broken dependencies:
sudo apt update
sudo apt checkThe 'apt check' command will display detailed information about conflicts and unmet dependencies. Note which packages are involved in the conflict.
APT can often resolve conflicts automatically by fixing broken dependencies:
sudo apt install -fThis attempts to fix any broken package dependencies. Review the output carefully to see which packages will be removed or modified. Type 'Y' only if the changes look correct.
If the previous step didn't work, configure any packages that are unpacked but not fully configured:
sudo dpkg --configure -a
sudo apt install -fThis completes any interrupted package installations before attempting to fix dependencies again.
Aptitude is more intelligent at resolving package conflicts than apt-get. It can suggest multiple solutions and let you choose:
sudo apt-get install aptitude
sudo aptitude install package-nameAptitude will present various scenarios to resolve the conflict, such as:
- Removing one of the conflicting packages
- Installing a different version
- Upgrading or downgrading related packages
Choose the option that best suits your needs. Option 1 is usually the safest starting point.
Conflicts often arise from third-party PPA repositories. List your sources and identify suspicious ones:
sudo add-apt-repository --listIf you find a PPA that's causing the conflict, remove it using:
sudo add-apt-repository --remove ppa:username/ppa-name
sudo apt update
sudo apt install -fAlternatively, use ppa-purge to remove a PPA and downgrade its packages to official versions:
sudo apt-get install ppa-purge
sudo ppa-purge ppa:username/ppa-nameIf none of the above works, perform a complete package manager reset:
sudo apt clean
sudo apt autoclean
sudo apt update
sudo dpkg --configure -a
sudo apt install -f
sudo apt dist-upgrade
sudo apt autoremove --purgeThese commands in sequence will:
- Remove cached package files
- Update package lists
- Configure pending packages
- Fix broken dependencies
- Perform a full system upgrade
- Remove unnecessary packages
This comprehensive approach resolves most conflicts, but may remove or upgrade some packages.
Sometimes packages are manually held at a specific version, preventing conflict resolution:
apt-mark showholdIf you see held packages listed, check if they're involved in the conflict. You can unhold them temporarily:
sudo apt-mark unhold package-name
sudo apt install -fRe-hold the package afterward if you want to keep it at a specific version:
sudo apt-mark hold package-nameFor users managing multiple PPAs or non-standard repositories: conflicts become more common when mixing packages from different sources. Consider using 'apt-cache policy package-name' to see which repositories provide each package version. This helps identify which PPA is causing the conflict.
On systems with Snap packages: mixing Snap and traditional apt packages occasionally causes conflicts. Use 'apt-cache policy package-name' to confirm which package manager owns a particular package.
For automated systems and CI/CD pipelines: always pin critical packages to specific versions in your infrastructure code rather than relying on automatic upgrades, which can introduce conflicts. Use 'apt-mark hold package-name' in deployment scripts.
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT