Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Berkshelf 3.x Integration #109

Closed
ehaselwanter opened this issue Feb 19, 2014 · 5 comments
Closed

Berkshelf 3.x Integration #109

ehaselwanter opened this issue Feb 19, 2014 · 5 comments

Comments

@ehaselwanter
Copy link

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

# get Berkshelf 3.0.beta

gem 'chef'
gem "berkshelf", github: "berkshelf/berkshelf"
gem 'knife-spork'

$ grep -e berkshelf -e knife-spork Gemfile.lock
  remote: git://github.com/berkshelf/berkshelf.git
    berkshelf (3.0.0.beta6)
      berkshelf-api-client (~> 1.1)
    berkshelf-api-client (1.1.1)
    knife-spork (1.3.2)
  berkshelf!
  knife-spork

  • does not work out of the box at all (must do a require 'berkshelf' in the runner.rb)
  • lockfile should be lockfile = ::Berkshelf::Lockfile.from_berksfile(berksfile)
  • load_from_berkshelf(name) is broken with berkshelf 3.x
knife spork upload base
ERROR: Berkshelf::BerkshelfError: LockFileNotFound

knife spork check base -VV
DEBUG: No chefignore file found at /Users/ehaselwanter/chef-repo-homenetwork/cookbooks/chefignore no files will be ignored
/Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/bundler/gems/berkshelf-eb7fc61e861e/lib/berkshelf/berksfile.rb:18:in `exist?': can't convert nil into String (TypeError)
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/bundler/gems/berkshelf-eb7fc61e861e/lib/berkshelf/berksfile.rb:18:in `from_file'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/gems/knife-spork-1.3.2/lib/knife-spork/runner.rb:147:in `load_from_berkshelf'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/gems/knife-spork-1.3.2/lib/knife-spork/runner.rb:132:in `load_cookbook'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/gems/knife-spork-1.3.2/lib/chef/knife/spork-check.rb:108:in `initial_load'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/gems/knife-spork-1.3.2/lib/chef/knife/spork-check.rb:49:in `run'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/gems/chef-11.10.2/lib/chef/knife.rb:491:in `run_with_pretty_exceptions'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/gems/chef-11.10.2/lib/chef/knife.rb:174:in `run'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/gems/chef-11.10.2/lib/chef/application/knife.rb:135:in `run'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/gems/chef-11.10.2/bin/knife:25:in `<top (required)>'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/bin/knife:23:in `load'
    from /Users/ehaselwanter/.rvm/gems/ruby-1.9.3-p484@cookbooks/bin/knife:23:in `<main>'

is there anybody working on this. or does nobody use berkshelf with spork.

I can do a

berks vendor
knife spork check base -o berks-cookbooks

but this is not what I want to do, and I get

WARNING: Your local version (0.2.2) is frozen on the remote server. You'll need to bump before you can upload.
Would you like to perform a patch-level bump on the base cookbook now? (Y/N)

with this

@jonlives
Copy link
Owner

@ehaselwanter this is covered by #85 - @sethvargo is going to have a look at Berkshelf 3 support in Spork once Berkshelf 3 has hit stable release status. Going to close this as a dupe for now - keep an eye on #85 for progress :)

@ehaselwanter
Copy link
Author

@sethvargo what is the correct substitution for

         cookbook = Berkshelf.ui.mute {
           self.config[:skip_dependencies] ||= false
           berksfile.resolve(lockfile.find(name), {skip_dependencies: self.config[:skip_dependencies]})[:solution].first
         }

in berkshelf 3.x (there is no resolve) and

lockfile = ::Berkshelf::Lockfile.from_berksfile(berksfile)
::Chef:: CookbookLoader.new(File.dirname(lockfile.find(name).cached_cookbook.path))[name]

does get me the cookbook but can not be loaded with the CookbookLoader.new

@mjuarez
Copy link

mjuarez commented Jun 24, 2014

This may be heading in the wrong direction, but I've been trying to make progress at this as well. I have the following which seems to load the cached cookbook...

      def load_from_berkshelf(name)
        return unless defined?(::Berkshelf)

        berksfile = ::Berkshelf::Berksfile.from_file(self.config[:berksfile])
        lockfile = ::Berkshelf::Lockfile.from_berksfile(berksfile)

        raise Berkshelf::BerkshelfError, "LockFileNotFound" unless File.exists?(lockfile.filepath)

        cookbook = lockfile.retrieve(name)

        #convert Berkshelf::CachedCookbook to Chef::CookbookVersion
        ::Chef::CookbookLoader.new(File.dirname(cookbook.path))[File.basename(cookbook.path)]

@jperry
Copy link
Contributor

jperry commented Jun 24, 2014

relates to #130

pivotal-casebook pushed a commit to Casecommons/knife-spork that referenced this issue Jul 9, 2014
Fix copied from mjuarez post here:

jonlives#109

ongoing other issue

jonlives#130
@grampajoe
Copy link

This is still an issue in 1.6.0, and masks problems in the load_from_chef method.

The specific issue I had was not having my cookbook_path set correctly, but seeing the LockFileNotFound error without any messages about not finding the cookbook locally. It took a while to realize it was falling through load_from_chef for me, but not for coworkers, and that the problem wasn't actually (or only) with Berkshelf.

Maybe it'd help to add feedback in load_from_{chef,berkshelf,librarian} to tell us which methods are failing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants