Package not installed by 'package' resource on ubuntu


I have a recipe that says (in part):

package 'libnetcdf-dev' do
   action :install

And when I run it it produces this output:

  * apt_package[libnetcdf-dev] action install
    - install version 1:4.4.0-2 of package libnetcdf-dev

However, after the chef-client run, the package is not installed:

ubuntu@linux1:~$ dpkg --get-selections|grep libnetcdf-dev

What’s going on?



I’m not real sure why you’re not getting an error. This:

package 'libnetcdf-dev' do
   action: install

I believe should be this (note the position of the colon):

package 'libnetcdf-dev' do
    action :install

Assuming that’s just a transcription error, I’m not sure why this wouldn’t work for you. I’ve put that through test kitchen and it seems to work OK for me. Are there other messages that might suggest something wrong with apt on the host? Does it converge successfully in test kitchen? Does a manual install of libnetcdf-dev work on the target host?


That was just a transcription error, I have edited the post to correct it. It does manually install with apt-get on the target host.
It does converge in test kitchen.

I did simplify my example a bit, the actual code is at

As you can see I list a whole bunch of packages and loop through each one and install it with
the package resource.
Just about all of the packages are installed, but libnetcdf-dev is not.
But as I mentioned, the output suggests it is installed.
chef-client ends without an error code, everything appears to have worked properly, but this package is not installed.
I’ve worked around it for now with

execute "install libnetcdf-dev" do
  command "apt-get install -y libnetcdf-dev"
  not_if "dpkg --get-selections libnetcdf-dev|grep -q libnetcdf-dev"

But that’s not really satisfactory, the package resource should work…


I spoke too soon. While it converges under test kitchen, the full recipe does not install the package there either.
If you put __END__ after line 244 (the end of the loop of calling package) you can see this for yourself.


Any logs if you run chef in debug mode?


Only info that indicates the package is being installed:

[2016-05-11T16:14:27-04:00] INFO: Processing apt_package[libnetcdf-dev] action install (BBS-provision-cookbook::default line 241)
[2016-05-11T16:14:27-04:00] DEBUG: Providers for generic apt_package resource enabled on node include: [Chef::Provider::Package::Apt]
[2016-05-11T16:14:27-04:00] DEBUG: Provider for action install on resource apt_package[libnetcdf-dev] is Chef::Provider::Package::Apt
[2016-05-11T16:14:27-04:00] DEBUG: apt_package[libnetcdf-dev] current version is nil
[2016-05-11T16:14:27-04:00] DEBUG: apt_package[libnetcdf-dev] candidate version is 1:4.4.0-2
[2016-05-11T16:14:27-04:00] DEBUG: apt_package[libnetcdf-dev] libnetcdf-dev not installed, installing 1:4.4.0-2
[2016-05-11T16:14:30-04:00] INFO: apt_package[libnetcdf-dev] installed libnetcdf-dev at 1:4.4.0-2

However, this does not install the package, and a subsequent run of the recipe, instead of saying “already installed, nothing to do”, installs it again. And yet it’s not actually installed.


Try to run that section with a cut down dependency list.

I’ve run into cookbooks using monkey patches in mixins that affect core chef resources and result in silent failures


Sorry for the long absence- I was counting on updates via email and either missed them or weren’t delivered. Not sure if you’re still having this problem, but I was poking around a bit to see if there was anything more I could figure out… it looks like there may be some conflicts in your requested packages.

When I run the “apt-get” command using all of the packages indicated I get the following output:

The following packages have unmet dependencies:
libcurl4-gnutls-dev : Conflicts: libcurl4-nss-dev but 7.47.0-1ubuntu2 is to be installed
                      Conflicts: libcurl4-openssl-dev but 7.47.0-1ubuntu2 is to be installed
 libcurl4-nss-dev : Conflicts: libcurl4-gnutls-dev but 7.47.0-1ubuntu2 is to be installed
                    Conflicts: libcurl4-openssl-dev but 7.47.0-1ubuntu2 is to be installed
 libcurl4-openssl-dev : Conflicts: libcurl4-gnutls-dev but 7.47.0-1ubuntu2 is to be installed
                        Conflicts: libcurl4-nss-dev but 7.47.0-1ubuntu2 is to be installed
 libhdf5-dev : Depends: libjpeg-dev
 libtiff5-dev : Depends: libjpeg-dev

Note that you’d only see this error if you list all of the packages on the apt-get command, vis:

apt-get ack-grep libnetcdf-dev libhdf5-serial-dev ...

So I can only think that installation of libnetcdf is creating or is a victim of a conflict and being uninstalled. This may still be a bug as the state of the system is not as written in your recipe, but I would suggest that rather than looping through the list, send the list to the package resource:

pkgs = %w(ack-grep libnetcdf-dev libhdf5-serial-dev sqlite ... )
package pkgs do
    action :install

This will shorten your converge time significantly and produce the real error being created in your package needs. As for where the conflict is being generated I can’t say, but curl and jpeg seem to be at the heart of the matter.

Hope this helps