This error occurs when the Pin-Priority field in /etc/apt/preferences or /etc/apt/preferences.d/ contains an invalid value. Pin-Priority must be a positive or negative integer, and common causes include non-numeric values, missing the Pin-Priority keyword, or incorrect syntax formatting.
APT (Advanced Package Tool) validates the syntax of your preferences configuration files when parsing them. The error "The value 'priority' is invalid for APT::Preferences" indicates that APT encountered a malformed or invalid value in the Pin-Priority field. This field controls package installation priorities and must be an integer between -1 and an upper limit (typically 1000+). When APT reads your preferences files, it strictly validates this field and will reject any non-numeric values, malformed syntax, or invalid configurations.
List and examine all APT preferences files:
cat /etc/apt/preferences
ls -la /etc/apt/preferences.d/Look for recently modified or added files. The error message typically indicates which file has the problem.
Ensure each preference block follows the correct format:
Package: package-name
Pin: release a=stable
Pin-Priority: 500
Package: another-package
Pin: origin example.com
Pin-Priority: 900Note that the keyword is Pin-Priority (not Priority), and the value must be a positive or negative integer.
Replace any non-numeric or text-based priority values with valid integers:
- Priority 0-99: Install only if no other version exists
- Priority 100-499: Install unless newer version from another source
- Priority 500-989: Install unless target release version is available
- Priority 990+: Install even if it's a downgrade
- Negative values: Prevent the version from being installed
Do NOT use text values like 'high', 'low', 'medium', or 'priority'.
Verify each preferences block is properly separated:
- Each block must end with a blank line (except the last block)
- No trailing whitespace after values
- File must end with a newline character
- Files in /etc/apt/preferences.d/ must have valid names (alphanumeric, hyphen, underscore, period only)
You can use a text editor to check:
nano /etc/apt/preferences
# or
vim /etc/apt/preferencesAfter making corrections, test the configuration:
apt-cache policyIf no errors appear, the syntax is valid. Then try a normal APT operation:
sudo apt updateIf you cannot identify the error, temporarily rename the preferences file:
sudo mv /etc/apt/preferences /etc/apt/preferences.bak
sudo apt updateIf this works, the issue was in the main preferences file. You can then examine the backup and fix it, or remove the file entirely if it's not needed.
The Pin-Priority field accepts any integer value, but APT interprets them in specific ranges. Values equal to 0 have undefined behavior and should never be used. If you're using preferences for multiple distribution pinning, remember that the first matching specific-form record wins, so place wildcard pins first. The files in /etc/apt/preferences.d/ are parsed in alphanumeric order, which can affect which rule takes precedence if multiple files define preferences for the same package. For debugging, you can run apt-cache policy <package> to see how APT is interpreting your preferences for a specific package.
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt