Search code examples
rubychef-infraberkshelfberksfile

Berks install not including ruby snippet


This is my berksfile:

source 'https://supermarket.chef.io'

Dir[File.expand_path('../cookbooks', __FILE__)].each do |path|
  cookbook(File.basename(path), path: path)
end

metadata

I should be able to do this https://www.sethvargo.com/berksfile-magic/ But berks just ignores that code snippet and I see no output from berks that it even tries to run it, it just says "Unable to find a solution for demands:"

If I include them like this it works:

cookbook 'mycookbook', path: '../mycookbook'

Solution

  • You probably meant Dir[File.expand_path('../cookbooks/*', __FILE__)] but you can do this more easily if you are using ChefDK 2.x (i.e. a recent-ish Berkshelf) like so:

    source 'https://supermarket.chef.io/'
    source chef_repo: '..'
    
    metadata