Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running Chef solo (version 11.4.0) on a clean VPS with Ubuntu 12 installed, and I'm having some problems with apt. The problem was that any package command raised an error:

apt-get -q -y install update-notifier-common=0.126 returned 100, expected 0

But, running that command on the shell worked perfectly.

After investigating it for a while I found that people recommended to run Opscode apt cookbook (version 1.9.0) in the run list before any cookbook. That way, some problems with apt-get update cache were solved.

So I put in my run list the cookbook apt first, and I'm still having the same errors:

Recipe: apt::default
* execute[apt-get-update] action run
  - execute apt-get update
* execute[apt-get update] action nothing (up to date)
* execute[apt-get autoremove] action nothing (up to date)
* execute[apt-get autoclean] action nothing (up to date)
* package[update-notifier-common] action install

Error executing action `install` on resource 'package[update-notifier-common]'

apt-get -q -y install update-notifier-common=0.126 returned 100, expected 0

Resource Declaration:
# In /home/ubuntu/.chef/toldo-cookbooks/cookbooks/apt/recipes/default.rb

 48: package "update-notifier-common" do
 49:   notifies :run, resources(:execute => "apt-get-update"), :immediately
 50: end

Compiled Resource:
# Declared in /home/ubuntu/.chef/toldo-cookbooks/cookbooks/apt/recipes/default.rb:48:in `from_file'

package("update-notifier-common") do
  action :install
  retries 0
  retry_delay 2
  package_name "update-notifier-common"
  version "0.126"
  cookbook_name :apt
  recipe_name "default"

[2013-02-24T19:31:10+00:00] ERROR: Running exception handlers
[2013-02-24T19:31:10+00:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated
[2013-02-24T19:31:10+00:00] FATAL: Stacktrace dumped to /home/ubuntu/.chef/toldo-cookbooks/chef-stacktrace.out
[2013-02-24T19:31:10+00:00] FATAL: Chef::Exceptions::Exec: package[update-notifier-common] (apt::default line 48) had an error: Chef::Exceptions::Exec: apt-get -q -y install update-notifier-common=0.126 returned 100, expected 0

Do you have some clue from where I can continue my investigation?

Many thanks!

share|improve this question
up vote 1 down vote accepted

It may be related to lack of privileges:

$ id
$ apt-get install vim # Just kidding!
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
$ echo $?

When I played with chef I used this:

# Usage:
# Chef::Provider::Package::Apt.send(:include, CustomApt::UseSudo)

module CustomApt
  module UseSudo
    def self.included(base)
      base.class_eval do

        alias_method :install_package_without_sudo, :install_package
        def install_package(name, version)
          package_name = "#{name}=#{version}"
          package_name = name if @is_virtual_package
            :command => "sudo apt-get -q -y#{expand_options(@new_resource.options)} install #{package_name}",
            :environment => {
              "DEBIAN_FRONTEND" => "noninteractive"

I included that in my recipes, i.e. install_packages.rb:

# So we install packages with sudo
Chef::Provider::Package::Apt.send(:include, CustomApt::UseSudo)

include_recipe "imagemagick::devel"

node['application']['install_packages'].each do |package_name|
  package package_name do
    action :install
share|improve this answer
you were right. It seems like a permission problem. I'm updating the way I run the cookbooks to do it as root. – blat Mar 3 '13 at 11:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.