How to fix E: Cannot mark package 'package-name' as automatically installed in APT
This error occurs when apt-mark cannot modify a package's installation status due to dependency conflicts or package state issues. Resolving dependency conflicts or using apt-get fix-broken to repair broken dependencies resolves this issue.
Quick fix
Fixes EMARKFAILED
apt-cache depends package-name
apt-cache rdepends package-name- Check the package dependency status
- Verify the package is installed
- Check for broken dependencies
- Use apt-get to mark the package
apt-cache depends package-nameapt-cache rdepends package-nameE: Cannot mark package 'package-name' as automatically installed
What this error means
The apt-mark command manages whether packages are marked as automatically installed (will be removed when no longer needed) or manually installed (kept even if no dependencies require them). This error occurs when apt-mark detects that changing a package's status would violate dependency constraints or when the package database is in an inconsistent state. When a package is marked as automatically installed, apt assumes it was only installed as a dependency and will remove it during 'apt autoremove' if nothing else depends on it. However, if marking a package as automatic would create an unresolvable dependency conflict—such as making a critical system package eligible for automatic removal—apt-mark refuses the operation to prevent system breakage.
Typical symptoms
- apt-mark auto command fails with 'Cannot mark' error
- Cannot change package installation status between auto and manual
- apt autoremove suggests removing packages you need
- Dependency chain appears broken or circular
Common causes
- Package has unmet or circular dependencies that would be violated by changing its status
- Package is required by another package but apt cannot determine the dependency relationship
- The package database is in an inconsistent state due to interrupted operations
- A previously held package is blocking the status change
- Conflicting version requirements exist between the package and its dependents
How to fix "E: Cannot mark package 'package-name' as automatically installed"
Run apt-cache depends package-name to see what packages depend on this one, and apt-cache rdepends package-name to see what requires it. This helps identify why apt-mark is refusing the status change.
apt-cache depends package-name
apt-cache rdepends package-nameConfirm the package is actually installed on your system. apt-mark can only change the status of installed packages.
dpkg -l | grep package-nameRun apt-get check to diagnose and apt-get -f install to fix any broken dependencies that may be preventing the status change.
sudo apt-get check
sudo apt-get -f installInstead of apt-mark, you can use apt-get directly, which may provide clearer error messages. However, this won't change the auto/manual status.
sudo apt-get install --no-upgrade package-nameIf the package state is corrupted, remove it completely and reinstall it. This resets its installation status.
sudo apt-get remove package-name
sudo apt-get install package-nameapt-mark requires root privileges. Ensure you're running it with sudo.
sudo apt-mark auto package-nameAdvanced notes
The 'Cannot mark' error is often a symptom of deeper dependency issues in your system. The apt resolver is sophisticated but can sometimes get stuck when packages have circular dependencies or when the dependency graph has conflicts. If you're unable to resolve this through the standard steps, you may need to use aptitude (sudo apt-get install aptitude) which has a more powerful resolver that can sometimes break deadlocks that apt cannot. Additionally, tools like 'apt-get build-dep' or 'apt-get source' may be needed to understand complex dependency relationships in development scenarios.
Frequently asked questions
- What does "EMARKFAILED" mean?
- The apt-mark command manages whether packages are marked as automatically installed (will be removed when no longer needed) or manually installed (kept even if no dependencies require them). This error occurs when apt-mark detects that changing a package's status would violate dependency constraints or when the package database is in an inconsistent state. When a package is marked as automatically installed, apt assumes it was only installed as a dependency and will remove it during 'apt autoremove' if nothing else depends on it.
- How do I fix "EMARKFAILED"?
- This error occurs when apt-mark cannot modify a package's installation status due to dependency conflicts or package state issues. Resolving dependency conflicts or using apt-get fix-broken to repair broken dependencies resolves this issue.
- What causes "EMARKFAILED"?
- Package has unmet or circular dependencies that would be violated by changing its status Package is required by another package but apt cannot determine the dependency relationship The package database is in an inconsistent state due to interrupted operations
- Is the "EMARKFAILED" 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
- 📖Ubuntu Manpage: apt-mark manual(Official Docs)
- 📖Debian Manpage: apt-mark(Official Docs)
- 📝
- 📖Debian FAQ - Package Management Tools(Official Docs)