Search code examples
rubyrubygemschef-infraberkshelfberksfile

Chef - Generating Berksfile on existing cookbook


A Berksfile is missing on a cookbook that's why I want to create a new one I just want to generate a berksfile on an existing cookbook. So when I try to run the command: berks cookbook name_of_my_cookbook

I'm getting the following error /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems.rb:271: in find_spec_for_exe: can't find gem berkshelf (>= 0.a) (Gem::GemNotFoundException) from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems.rb:299:in activate_bin_path from /usr/local/bin/berks:23:in'

I tried to install berkshelf again via gem install berkshelf but I'm getting another error message: ERROR: Error installing berkshelf: There are no versions of solve (~> 4.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for? solve requires Ruby version >= 2.1.0. The current ruby version is .

I have no other idea to solve this issue. I'm quite a newbie on this so I appreciate any help.


Solution

  • There is no reason to use berks cookbook anymore and I'm pretty sure it was removed years ago. It sounds like your first problem is that your gem environment is very broken. We only support Berkshelf via the ChefDK installers, not gem install berkshelf. You appear to have the chef-client installer, not ChefDK, so fix that first. Then if you just want a standard Berksfile it's:

    source "https://supermarket.chef.io/"
    metadata