How to fix E: Package 'package-name' is a virtual package provided by multiple packages in APT
This error occurs when you try to install a virtual package that multiple real packages can provide, and apt cannot automatically choose which one you want. The solution is to explicitly select one of the concrete packages instead of the virtual package name.
Quick fix
Fixes E: Package 'package-name' is a virtual package provided by multiple packages
apt-cache showpkg libxaw-dev- Identify which packages provide the virtual package
- Choose the most appropriate concrete package
- Install the concrete package instead
- Update your installation scripts or Dockerfiles
apt-cache showpkg libxaw-devE: Package 'package-name' is a virtual package provided by multiple packages
What this error means
A virtual package in Debian/Ubuntu is a package name that does not correspond to any real installable package. Instead, multiple real packages declare that they "provide" that virtual package name. When you try to install a virtual package and multiple options exist, apt refuses to proceed because it cannot know which concrete implementation you want. This is a safety feature to prevent accidentally installing the wrong variant. Virtual packages are commonly used for packages like mail-transport-agent (provided by postfix, sendmail, exim, etc.), libxaw-dev (provided by libxaw7-dev and libxaw6-dev), or linux-headers (provided by multiple version-specific packages).
Typical symptoms
- apt install command fails with "is a virtual package provided by multiple packages" error
- No error is shown by apt search, but installation fails when you try apt install
- You see a list of packages that can provide the virtual package, but apt refuses to choose one
- Build systems or installation scripts fail because they cannot install a required virtual package
Common causes
- Trying to install a virtual package (not a real package) that has multiple providers
- Not specifying which concrete package you want when multiple options exist
- Using generic package names (like linux-headers) instead of version-specific ones (like linux-headers-5.15.0-generic)
- Copy-pasting installation instructions that worked on a different system with different packages available
How to fix "E: Package 'package-name' is a virtual package provided by multiple packages"
Run apt-cache showpkg package-name to see which real packages provide the virtual package:
apt-cache showpkg libxaw-devOr use apt-cache search --names-only "^package-name$" to check if it is indeed virtual:
apt-cache search --names-only "^libxaw-dev$"Look for lines that say "Provides:" - these are the real packages you can install instead.
From the list of packages that provide the virtual package, select the one that best matches your needs. For example:
- For libxaw-dev: Choose libxaw7-dev for newer systems or libxaw6-dev for older ones
- For linux-headers: Choose linux-headers-5.15.0-generic (matching your kernel version)
- For mail-transport-agent: Choose postfix, exim4, or sendmail based on your preference
If unsure, use apt-cache show package-name to read the description of each option:
apt-cache show libxaw7-dev
apt-cache show libxaw6-devReplace the virtual package name with the real package name in your apt install command:
# Instead of this (fails):
sudo apt install libxaw-dev
# Do this (works):
sudo apt install libxaw7-devFor linux-headers, first check your kernel version:
uname -rThen install the matching headers package:
sudo apt install linux-headers-5.15.0-genericIf this error appears in automated scripts, update them to specify the concrete package name. In Dockerfiles, you can check the system version first:
RUN apt-get update && apt-get install -y ca-certificates
# For package variants, specify explicitly
RUN apt-get install -y libxaw7-dev
# For linux-headers, use a specific version
RUN apt-get install -y linux-headers-$(uname -r)Or use the dpkg approach to detect and install:
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential linux-headers-genericIf you need a specific file or library, use apt-file to find which concrete package provides it:
# Install apt-file if needed
sudo apt install apt-file
sudo apt-file update
# Search for files
apt-file search /usr/include/X11/Xaw/Command.hThis tells you exactly which package provides the file you need, removing all ambiguity.
Advanced notes
Virtual packages are a powerful feature in Debian/Ubuntu but can be confusing for new users. They serve multiple purposes: allowing users to choose between equivalent implementations (mail-transport-agent), providing backwards compatibility as packages evolve (libxaw-dev providing both libxaw6-dev and libxaw7-dev), and creating aliases for packages with multiple versions (linux-headers for kernel-specific packages). The key principle is that apt will never automatically choose for you when multiple options exist - you must make the choice explicitly. This is by design, as automatically selecting the wrong variant could cause subtle compatibility issues. In build environments or Docker, consider pinning to specific package versions to avoid this issue entirely: instead of depending on virtual packages, list the exact concrete packages your code needs.
Frequently asked questions
- What does "E: Package 'package-name' is a virtual package provided by multiple pa" mean?
- A virtual package in Debian/Ubuntu is a package name that does not correspond to any real installable package. Instead, multiple real packages declare that they "provide" that virtual package name. When you try to install a virtual package and multiple options exist, apt refuses to proceed because it cannot know which concrete implementation you want.
- How do I fix "E: Package 'package-name' is a virtual package provided by multiple pa"?
- This error occurs when you try to install a virtual package that multiple real packages can provide, and apt cannot automatically choose which one you want. The solution is to explicitly select one of the concrete packages instead of the virtual package name.
- What causes "E: Package 'package-name' is a virtual package provided by multiple pa"?
- Trying to install a virtual package (not a real package) that has multiple providers Not specifying which concrete package you want when multiple options exist Using generic package names (like linux-headers) instead of version-specific ones (like linux-headers-5.15.0-generic)
- Is the "E: Package 'package-name' is a virtual package provided by multiple pa" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐APT Official Documentation
- ๐Debian Wiki - Virtual Packages(Official Docs)
- ๐Debian Manpage - apt-cache(Official Docs)
- ๐Debian Policy Manual - Package Relationships(Official Docs)
- ๐