How to fix E: Cannot mark package as manually installed in APT

APTINTERMEDIATEMEDIUMUpdated Dec 29, 2025ยท 124 views

This error occurs when apt cannot mark a package as manually installed, typically because the package is virtual, not installed, or has dependency issues. Virtual packages are references to other packages and cannot be directly marked as manually installed.

Quick fix

Fixes E: Cannot mark package as manually installed

dpkg -l | grep package-name
  1. Verify the package is actually installed
  2. Check if the package is virtual
  3. Refresh the APT cache
  4. Check package installation status
apt โ€” error
dpkg -l | grep package-name
E: Cannot mark package as manually installed

What this error means

The "E: Cannot mark package as manually installed" error means that apt's `apt-mark manual` command cannot mark the specified package as manually installed. This happens for several reasons: When you install a package manually (explicitly requesting it), apt marks it as "manually installed" to protect it from being automatically removed when it's no longer a dependency of other packages. Conversely, packages installed as dependencies are marked as "automatically installed" and can be removed by `apt autoremove` if nothing needs them. The error occurs when apt cannot perform this marking operation, usually because the target is a virtual package (which doesn't have a physical installation), the package isn't actually installed, or dependency resolution prevents the marking.

Typical symptoms

  • Error message appears when running 'apt-mark manual package-name'
  • Virtual packages like 'java-runtime' or 'python' cannot be marked
  • Attempting to protect a package from autoremove fails
  • The package name appears in search results but cannot be marked
  • Related packages can be marked but the target package cannot

Common causes

  1. The package is virtual (a placeholder referring to other packages that provide it)
  2. The package is not actually installed on your system
  3. The package was removed but its configuration remains
  4. Dependency conflicts prevent the marking operation
  5. The package is a metapackage or non-installable package
  6. APT cache is corrupted or out of sync

How to fix "E: Cannot mark package as manually installed"

1Verify the package is actually installed

First, check if the package is truly installed on your system:

bash
dpkg -l | grep package-name

or more specifically:

bash
dpkg -l | grep '^ii' | grep package-name

The output should show lines starting with ii (installed). If you see nothing, the package is not installed. You cannot mark a non-installed package as manually installed.

If the package is not installed, install it first:

bash
sudo apt install package-name

Then try marking it:

bash
sudo apt-mark manual package-name
2Check if the package is virtual

Virtual packages are references to other packages and cannot be directly marked. Check if your package is virtual:

bash
apt-cache show package-name | grep -E '^(Package|Virtual):'

If the output shows "Virtual: yes" or "Provides:", the package is virtual. Virtual packages are typically metapackages like:
- java-runtime (virtual, provided by openjdk-11-jre, openjdk-17-jre, etc.)
- python (virtual, provided by specific Python versions)
- mailserver (virtual, provided by postfix, sendmail, etc.)

Solution for virtual packages: Mark the real package that provides it instead:

bash
# Find what provides the virtual package
apt-cache depends --recurse package-name

# Then mark the concrete package:
sudo apt-mark manual openjdk-11-jre

Or use apt-cache rdepends to see reverse dependencies:

bash
apt-cache rdepends package-name
3Refresh the APT cache

A corrupted or out-of-sync APT cache can cause marking issues. Refresh it:

bash
sudo apt update

Then try marking the package again:

bash
sudo apt-mark manual package-name

If that still fails, you can clean the cache and rebuild it:

bash
sudo apt clean
sudo apt update

The apt clean command removes cached package files (you can safely delete these), while apt update refreshes the package list from repositories.

4Check package installation status

Get detailed information about the package's installation state:

bash
apt-cache policy package-name

This shows:
- Candidate version (what would be installed)
- Installed version (what's actually on your system)
- Available versions from repositories

Also check if it's marked as on-hold:

bash
apt-mark showhold

If your package is in the hold list, it might prevent marking:

bash
sudo apt-mark unhold package-name
sudo apt-mark manual package-name
5Resolve dependency conflicts

If the package has unmet dependencies, apt may refuse to mark it. Check for issues:

bash
sudo apt --fix-broken install

This command tries to fix dependency issues without making changes:

bash
sudo apt check

If there are broken dependencies, fix them first before marking:

bash
# Show what depends on this package
apt-cache rdepends package-name

# Show what this package depends on
apt-cache depends package-name

# Try to fix dependency issues
sudo apt --fix-broken install

After resolving dependencies, try marking again:

bash
sudo apt-mark manual package-name
6Use the correct package name

Package names are case-sensitive and may differ from what you expect. Find the exact name:

bash
apt search pattern

For example:

bash
# Wrong: trying to mark 'Java'
sudo apt-mark manual Java
# Error: Package not found

# Correct: use the actual package name
apt search java-runtime
sudo apt-mark manual default-jre

Common package name confusions:
- node vs nodejs (Node.js)
- python vs python3 vs python3.10 (specific Python version)
- java vs default-jre vs openjdk-11-jre (Java runtime)
- docker vs docker.io (Docker)

Always use:

bash
apt-cache show package-name

to confirm the package exists before trying to mark it.

7Mark the package as auto, then back to manual

Sometimes resetting the marking state helps resolve conflicts. Try this sequence:

bash
# Check current state
apt-mark showmanual | grep package-name

# Try marking as auto first
sudo apt-mark auto package-name

# Then mark as manual
sudo apt-mark manual package-name

If the package is already in the manual list, this refresh can clear any state issues.

You can also view all manually and automatically installed packages:

bash
# Show all manually installed packages
apt-mark showmanual

# Show all automatically installed packages
apt-mark showauto

# Count them
apt-mark showmanual | wc -l
apt-mark showauto | wc -l

Advanced notes

Understanding APT's marking system: The status of packages is tracked in the APT database (/var/lib/apt/extended_status). When you mark a package as manual, you're telling APT that this package was explicitly requested by the user, not pulled in as a dependency. This status survives upgrades and is crucial for apt autoremove to work correctly.

Virtual packages in depth: Virtual packages are declared in the Provides field of actual packages. For example:

bash
# java-runtime is virtual, provided by many concrete packages:
apt-cache search java-runtime
# Shows providers like: default-jre, openjdk-11-jre, openjdk-17-jre, etc.

Virtual packages are useful for dependencies that don't care which implementation is used, but they cannot be installed or marked directly.

Metapackages: Some packages (often ending in -meta) are metapackages that exist only to bring in other packages. These can be marked but are lightweight wrappers:

bash
apt-cache show ubuntu-desktop
# This is a metapackage that depends on many GUI packages

Dependency resolution order: When APT installs a package, it marks:
- The explicitly requested package: manual
- All dependencies pulled in: auto

If you later explicitly install a package that was previously auto, apt automatically marks it as manual.

Checking mark status programmatically: You can query the APT database directly:

bash
# Dump extended status
grep -E '^(Package|Auto-Installed):' /var/lib/apt/extended_status | paste - - | grep package-name

APT cache clearing: If you suspect corruption:

bash
# Dangerous: removes all cached data
sudo rm -rf /var/lib/apt/extended_status
sudo apt update

# Or more safely, use:
sudo apt clean
sudo apt update

Frequently asked questions

What does "E: Cannot mark package as manually installed" mean?
The "E: Cannot mark package as manually installed" error means that apt's apt-mark manual command cannot mark the specified package as manually installed. This happens for several reasons: When you install a package manually (explicitly requesting it), apt marks it as "manually installed" to protect it from being automatically removed when it's no longer a dependency of other packages. Conversely, packages installed as dependencies are marked as "automatically installed" and can be removed by apt autoremove if nothing needs them.
How do I fix "E: Cannot mark package as manually installed"?
This error occurs when apt cannot mark a package as manually installed, typically because the package is virtual, not installed, or has dependency issues. Virtual packages are references to other packages and cannot be directly marked as manually installed.
What causes "E: Cannot mark package as manually installed"?
The package is virtual (a placeholder referring to other packages that provide it) The package is not actually installed on your system The package was removed but its configuration remains
Is the "E: Cannot mark package as manually installed" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading