Aptitude ignores /etc/apt/preferences.d/*

Bug #508545 reported by Nikolaus Rath on 2010-01-16
This bug affects 43 people
Affects Status Importance Assigned to Milestone
Fix Released
aptitude (Ubuntu)

Bug Description

Binary package hint: aptitude

Aptitude honors pinning settings in /etc/apt/preferences, but ignores any settings in /etc/apt/preferences.d/*.

To reproduce, add

 deb http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu karmic main

to your sources list and and entry of the form

  Package: *
  Pin: release o=LP-PPA-ubuntu-mozilla-daily
  Pin-Priority: 101

to the preferences file and observe that aptitude will try to upgrade firefox if the setting is in /etc/apt/preferences.d/, and (correctly) stick with the karmic version of the setting is made in /etc/apt/preferences.

Stephen (kernelpanic.ca) wrote :
Download full text (3.8 KiB)

I can confirm this bug. (or I am doing something completely wrong)

   I would like to install one package from karmic-proposed and all other packages from karmic, karmic-updates, or karmic-security. I added the karmic-proposed repository to sources, and a pinning block to apt/prferences.d. The command "apt-cache policy" shows the packages from karmic-proposed at a low priority. The command "apt-get upgrade" respects the priorities. The command "aptitude safe-upgrade" does not respect the priorities and attempts to upgrade all packages from karmic-proposed.

 As seen below apt-cache policy reports that the package "cups" (chosen for example) should be install/upgraded from the karmic-security archive. The command apt-get upgrade reports that all packages are up to date as expected. The command aptitude safe-upgrade attempts to install 64 news packages which goes against the policy set in apt/preferences.d/local-pin

Ubuntu: karmic
platform: amd64

All packages up to date from karmic, karmic-updates, karmic-security as of 1 Feb 2010.

Package: aptitude

Package: apt

Package: *
Pin: release a=karmic-proposed
Pin-Priority: 50

deb http://ca.archive.ubuntu.com/ubuntu/ karmic main restricted universe
deb http://ca.archive.ubuntu.com/ubuntu/ karmic-security main restricted universe
deb http://ca.archive.ubuntu.com/ubuntu/ karmic-updates main restricted universe
deb http://ca.archive.ubuntu.com/ubuntu/ karmic multiverse
deb http://ca.archive.ubuntu.com/ubuntu/ karmic-updates multiverse
deb http://security.ubuntu.com/ubuntu karmic-security multiverse
deb http://ca.archive.ubuntu.com/ubuntu/ karmic-proposed main multiverse universe

$ apt-cache policy cups
  Installed: 1.4.1-5ubuntu2.1
  Candidate: 1.4.1-5ubuntu2.1
  Version table:
     1.4.1-5ubuntu2.2 0
         50 http://ca.archive.ubuntu.com karmic-proposed/main Packages
 *** 1.4.1-5ubuntu2.1 0
        500 http://ca.archive.ubuntu.com karmic-security/main Packages
        500 http://ca.archive.ubuntu.com karmic-updates/main Packages
        100 /var/lib/dpkg/status
     1.4.1-5ubuntu2 0
        500 http://ca.archive.ubuntu.com karmic/main Packages

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo aptitude safe-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Resolving dependencies...
Resolving dependencies...
The following NEW packages will be installed:
  linux-headers-2.6.31-18{a} linux-headers-2.6.31-18-generic{a}
The following packages will be upgraded:
  aisleriot compiz-core compiz-gnome compiz-plugins compiz-wrapper cups
  cups-bsd cups-client cups-common cups-ppdc cupsddk devicekit-power
  glchess glines gnect gnibbles gnobots2 gnome-blackjack gnome-games
  gnome-games-common gnome-mahjongg gnome-power-manager gnome-sudoku
  gnometris gnomine gnotravex gno...


Nikolaus Rath (nikratio) on 2010-02-01
Changed in aptitude (Ubuntu):
status: New → Confirmed
Dominik (domfi) wrote :

Same problem here with Lucid.
aptitiude seems to use /etc/apt/preferences but not /etc/apt/preferences.d/*


Stephen (kernelpanic.ca) wrote :

Thank you Dominik. I thought I had tested /etc/apt/preferences but obviously I had not.

Under Karmic aptitude does respect the policies set in /etc/apt/preferences but not preferences.d/*. The tools apt-cache and apt-get also respect the policies in /etc/apt/preferences.

Nikolaus Rath (nikratio) on 2010-02-06
summary: - Aptitude ignores apt_preferences
+ Aptitude ignores apt_preferences.d/*
summary: - Aptitude ignores apt_preferences.d/*
+ Aptitude ignores preferences.d/*
description: updated

Still affects aptitude on Ubuntu 10.04 as of 24 Mar 2010.

It just merrily munched my custom-rebuilt netatalk package, knocking all the Mac OS 9 systems required for critical legacy apps off the network. Ouch!

$ cat /etc/apt/preferences.d/netatalk
Package: netatalk
Pin: origin ""
Pin-Priority: 1001

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

$ sudo aptitude safe-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
The following packages will be upgraded:
The following packages are RECOMMENDED but will NOT be installed:
  libpam-cracklib rc
1 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/831kB of archives. After unpacking 81.9kB will be freed.
Do you want to continue? [Y/n/?]

Jesse (sbjesse) on 2010-03-27
description: updated
Changed in aptitude:
status: Unknown → New
mariodebian (mariodebian) wrote :


I was looking at source code of apt:

apt- (line 283)

   vector<string> const List = GetListOfFilesInDir(Dir, "pref", true, true);

Second argument of GetListOfFilesInDir is extension filenames (defined in apt-pkg/contrib/fileutl.cc)

 preferences.d/* files must have .pref extension, example /etc/apt/preferences.d/local-pin.pref

intuited (intuited) wrote :

In response to @mariodebian's comment (#6):
  Using the karmic version of aptitude (, files in /etc/preferences.d are ignored even if they have the .pref extension.

Anders Kaseorg (andersk) on 2010-05-07
summary: - Aptitude ignores preferences.d/*
+ Aptitude ignores /etc/apt/preferences.d/*

I tried it too; aptitude ignores .pref files. But apt-cache policy shows it as it should.

Jean-Pierre Rupp (xenog) wrote :

I can confirm this bug. I created a file with pinning settings in /etc/apt/preferences.d, but aptitude or the Gnome tools used by Ubuntu ignored it (apt-get worked fine). I moved the contents of the file to /etc/apt/preferences (file) and everything was OK.

Simon Déziel (sdeziel) wrote :

This bug also affects the Lucid version of aptitude. I tried with a file in /etc/apt/preferences.d/ without extension and with .pref extension and the bug still manifests.

# cat /etc/apt/preferences.d/test.pref
Package: libldap-2.4-2
Pin: release a=lucid-updates
Pin-Priority: -10

Package: libldap2-dev
Pin: release a=lucid-updates
Pin-Priority: -10

# aptitude safe-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
The following packages will be upgraded:
  libldap-2.4-2 libldap2-dev
2 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,189kB of archives. After unpacking 0B will be used.
Do you want to continue? [Y/n/?]

# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid

# apt-cache policy aptitude
  Version table:
 *** 0
        500 http://archive.ubuntu.com/ubuntu/ lucid/main Packages
        100 /var/lib/dpkg/status

Changed in aptitude:
status: New → Fix Committed
Changed in aptitude:
status: Fix Committed → Fix Released
intuited (intuited) wrote :

Is this supposed to be fixed in updated versions of Maverick? Sorry if that's a silly question — is there a better way to find out which version of aptitude has this fix? I've got my system updated but it looks like aptitude is still not finding files like ``/etc/apt/preferences.d/identifier.pref``.

Germán Pabón (ninboy) wrote :

Usually when the fix is committed to some repository, the Bug Watcher Updater post here with the version it should be fixed. This is probably waiting for some approval or confirmation...

Anders Kaseorg (andersk) wrote :

This is fixed in natty’s aptitude 0.6.3-3.2ubuntu1.

aptitude (0.6.3-3.2ubuntu1) natty; urgency=low

  * Merge from debian unstable. Remaining changes:
    - debian/05aptitude: never autoremove kernels
    - drop aptitude-doc to Suggests
    - 01_intltool_update.dpatch: run intltool-update against the source
      directory, so that irrelevant cosmetic .po file changes don't end up
      tangled in other patches.
    - 03_branding.dpatch: ubuntu branding
    - 04_changelog.dpatch: take changelogs from changelogs.ubuntu.com
    - 09_ubuntu_fortify_source.dpatch: Suppress a number of warnings (turned
      into errors by -Werror) triggered by Ubuntu's default of
    - 11_ubuntu_uses_sudo.dpatch: fix status line of 'Become root' menu entry
      to not refer to su.
    - 12_point_manpage_to_doc_package.dpatch: point Finnish manpage to the
      correct place for further info
  - debian/rules: build with --disable-werror
    - 14_html2text_preferred.dpatch: switch back to html2text in favor of
      elinks, since html2text is in main and elinks isn't.
  * dropped:
    - 13_screensize.dpatch: applied upstream
    - 15_ftbfs_new_apt.dpatch: applied upstream

 -- Michael Vogt <email address hidden> Thu, 18 Nov 2010 09:46:28 +0100

aptitude (0.6.3-3.2) unstable; urgency=low

  * Non-maintainer upload.
  * 0007-preferences-dir.patch: Patch to support /etc/apt/preferences.d/
    directory. (Closes: #557580)
  * debian/rules: Fix clean rule. Patch by Stéphane Glondu.
    (Closes: #594505)

 -- Tim Retout <email address hidden> Tue, 12 Oct 2010 21:11:54 +0100

Changed in aptitude (Ubuntu):
status: Confirmed → Fix Released
Joel Ebel (jbebel) on 2010-12-02
tags: added: glucid lucid
Bastien Durel (bastien-durel) wrote :


It would be great if it can it pushed, at least in maverick-proposed

astrostl (astrostl) wrote :

Will a fix be pushed to Lucid LTS?

tags: added: maverick
astrostl (astrostl) wrote :

Lucid LTS? :'(

Roland Hieber (rohieb) wrote :

Yes, please?

Rolf Leggewie (r0lf) wrote :
Michael Vogt (mvo) wrote :

I uploaded this to lucid-proposed now.

Changed in aptitude (Ubuntu Lucid):
status: New → In Progress

Hello Nikolaus, or anyone else affected,

Accepted aptitude into lucid-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in aptitude (Ubuntu Lucid):
status: In Progress → Fix Committed
tags: added: verification-needed
Rolf Leggewie (r0lf) wrote :

I did "sudo mv /etc/apt/preferences /etc/apt/preferences.d/" before adding the package from -proposed. My lucid system still correctly shows me the pinning values. So, I cannot verify that the current lucid package ignores /etc/apt/preferences.d/*

astrostl (astrostl) wrote :

Thx for the Lucid updates!

Rolf Leggewie (r0lf) wrote :

astrostl, this is not yet generally released. For that to happen, verification needs to happen as explained in #20. I suppose you were previously affected, can you verify that the package currently in -proposed fixes the issue for you? I was unable to verify that the bug even affects me!

astrostl (astrostl) wrote :

I'm not working with Ubuntu systems, as I was when I made the request. Just wanted to offer thanks.

Wesley Schwengle (wesleys) wrote :

I can confirm the bug is fixed in Lucid. Aptitude now respects the preferences file(s) in /etc/apt/preferences.d/.

It is very easy to replicate.

Create a preferences file:

Package: totem-mozilla
Pin: version 2.30.0git20100413-0ubuntu1
Pin-Priority: 1001

Remove totem-mozilla package.

Install it, you will get BROKEN package messages (expected).
Now move the preferences file to /etc/apt/preferences.d and install totem-mozilla once again. It will now install the highest possible version which should not happen.

Install the -proposed aptitude version and rinse repeat, now you will get in either situation (/etc/apt, /etc/apt/preferences.d) the BROKEN package message (as expected).

Rolf Leggewie (r0lf) wrote :

Wesley, as you can see from my comment #23 I already have a pinning preferences file. And the correct values are picked up whether the file is named /etc/apt/preferences or /etc/apt/preferences.d/preferences. Therefore, as far as I am concerned the issue does not exist.

How about you run the following cadence instead with the old aptitude package installed?

+--[ /etc/apt/preferences.d/lp508545 ]
| Package: *
| Pin: release a=lucid-proposed
| Pin-Priority: 99

Then, show us the output of "apt-cache policy aptitude". For me, that snippet works in BOTH locations, i.e. no bug.

tags: added: verification-done
removed: verification-needed
Rolf Leggewie (r0lf) wrote :

I'd appreciate somebody reconfirm what I wrote in #23 and #26 before this is considered ready for upload to -updates. Again, the issue as I understand it does not exist here.

Wesley Schwengle (wesleys) wrote :

@Rolf, apt-cache is NOT aptitude. It is provided by the apt package not by aptitude. So you see the correct pinning values with apt-cache policy, but aptitude is not respecting it. Which is the bug :)

In other words, replace install the totem-mozilla package with : aptitude -y -s totem-mozilla with the snippet in both locations and you will be able to replicate the bug (my snippet, not yours, unless totem-mozilla is also found in -proposed).

Nikolaus Rath (nikratio) wrote :

Rolf, 35 people confirmed this bug. If you look at the debdiff above, it's also very obvious that there has been a problem. Please stop spamming.

I have reproduced the problem with aptitude in lucid following the steps described by Wesley in comment 25 and have verified that the version of aptitude in -proposed fixes the issue.

Rolf Leggewie (r0lf) wrote :

Nikolaus, I'm the one driving progress in this bug for the last few days. Without my work you'd still be twiddling your thumbs, my friend. And making sure an SRU is indeed warranted is not spamming. So, how about a little appreciation from your side for other people fixing YOUR problem? If you feel spammed, there's always the option for you to unsubscribe from your very own ticket.

@Wesley, point taken. Thank you.

Rolf Leggewie (r0lf) wrote :

@Jean-Baptiste, thank you.

Nikolaus Rath (nikratio) wrote :

Ralf, you are right, my apologies. I have since transitioned away from Ubuntu, because for me bugfixes took too long to reach LTS releases. That is probably the reason why I get quickly annoyed when asked to reconfirm bugs or fixes. There are several bugs that I've been reconfirming every 6 months for years, with nothing ever happening other than "please confirm that this still is a problem".

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package aptitude -

aptitude ( lucid-proposed; urgency=low

  * backport 0007-preferences-dir.patch from natty. (LP: #508545)
 -- Rolf Leggewie <email address hidden> Wed, 19 Oct 2011 23:45:52 +0800

Changed in aptitude (Ubuntu Lucid):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.