Package Management (Apt/Dnf/Pacman Internals)
Stop apt from ignoring your carefully crafted preferences
🧩 The Challenge
You ever pin a package to a specific version or archive, only for apt to completely ignore your rules and grab the latest garbage anyway? I spent an entire morning once trying to figure out why my production node kept pulling a dev branch of a dependency despite my /etc/apt/preferences file looking perfectly set up.
💡 The Fix
You need to check the effective priority calculation using the cache policy command to see exactly which rules are colliding. It tells you exactly what apt is thinking before you hit enter on that upgrade.
apt-cache policy package_name
⚙️ Why It Works
This utility dumps the internal priority calculation and candidate selection logic, showing you if your pin matches the release or version string correctly. Most of the time you’ll see your pin sitting at a lower priority than the default, which is why your rule is getting tossed in the trash.
🚀 Pro-Tip: Always run this before applying a hold or a pin to make sure the regex or package name actually resolves to the target you think it does.
Linux Tips & Tricks | © ngelinux.com | 9/3/2026
