Installing ChefDK and allowing it to use Berksfile in version 2.x format. This also helps resolving the nokogiri issue for installing .


Using ChefDK to create and or manage existing cookbooks. When installing the software it has its own embedded ruby environment with its necessary version of berkshelf. When you want to use an older version of berks along side ChefDK you sometimes get an error with nokogiri. This post helps resolve that error.


After installing ChefDK, goto your cookbook with the Gem file and Berksfile that says something to the order of:

# ./Gemfile
source 'https://rubygems.org'

gem 'berkshelf', '~> 2.0.0'

# ./Berksfile
chef_api :config

You need to get your own berks installed to your home directories berks path:

For RedHat Linux

yum install libxml2-devel
bundle config build.nokogiri "--use-system-libraries=true --with-xml2-include=/usr/include/libxml2/"
bundle install

If for some reason this does not work, run the following:

gem install nokogiri -v '' -- "--use-system-libraries=true --with-xml2-include=/usr/include/libxml2/"
bundle install

For Mac OS X

brew install libxml2
bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"
bundle install
comments powered by Disqus