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.
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).
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.
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.
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