Closed joelmoss closed 9 years ago
Ah no matter. My bad. II forgot run use chef exec ...
Hey @joelmoss,
This whole chef exec
and bundle exec
thing can be highly confusing. chef-runner should work fine with chef shell init
though, at least under Linux/Mac.
I'm always looking for ways to improve chef-runner's integration with other tools, in particular with ChefDK. So if you have any ideas, feel free to share them here.
I am running into this same error, even using exec. Am I doing something wrong?
chef exec "chef-runner -H ubuntu@ec2-174-129-84-24.compute-1.amazonaws.com conjurops-jenkins::slave -i true -l debug"
INFO: Starting chef-runner (v0.8.0 darwin/amd64)
INFO: Run list is [conjurops-jenkins::slave -i true -l debug]
INFO: Preparing local files
INFO: Installing cookbook dependencies with Berkshelf resolver
-e:1:in `require': cannot load such file -- berkshelf (LoadError)
from -e:1:in `<main>'
ERROR: exit status 1
This works just fine
chef exec ruby -e "require 'berkshelf'"
@dustinmm80 Please provide a bit more context.
chef shell-init
?Also please run chef-runner with CHEF_RUNNER_LOG=debug
set in the environment and post the output here.
Yes, there is a Gemfile:
source 'https://rubygems.org'
gem 'conjur-api', github: 'conjurinc/api-ruby', branch: 'master'
gem 'conjur-cli', github: 'conjurinc/cli-ruby', branch: 'master'
Using ChefDK v0.3.5
chef-runner gives me the same error using chef shell-init
, that's my default use case.
Debug log:
➜ conjurops-jenkins git:(master) ✗ CHEF_RUNNER_LOG=debug chef exec "chef-runner -H ubuntu@ec2-174-129-84-24.compute-1.amazonaws.com conjurops-jenkins::slave -i true"
INFO: Starting chef-runner (v0.8.0 darwin/amd64)
DEBUG: Cookbook = conjurops-jenkins 0.1.0
INFO: Run list is [conjurops-jenkins::slave -i true]
DEBUG: Provisioner = {RunList:[conjurops-jenkins::slave -i true] Attributes: Format: LogLevel: UseSudo:true ChefVersion:}
INFO: Preparing local files
DEBUG: Creating local sandbox in .chef-runner/sandbox
DEBUG: Preparing JSON data
DEBUG: Preparing Chef Solo config
DEBUG: Preparing cookbooks
INFO: Installing cookbook dependencies with Berkshelf resolver
DEBUG: exec: bundle exec ruby -e require "berkshelf"; b = Berkshelf::Berksfile.from_file("Berksfile"); Berkshelf::Berksfile.method_defined?(:vendor) ? b.vendor(".chef-runner/sandbox/cookbooks") : b.install(:path => ".chef-runner/sandbox/cookbooks")
-e:1:in `require': cannot load such file -- berkshelf (LoadError)
from -e:1:in `<main>'
ERROR: exit status 1
I wasn't able to reproduce this yet.
However, I spotted a different problem. This tells me that the order of command-line args is wrong.
INFO: Run list is [conjurops-jenkins::slave -i true]
It should be:
$ chef-runner -H ubuntu@ec2-174-129-84-24.compute-1.amazonaws.com -i true conjurops-jenkins::slave
Seems like it might be a bundler + ChefDK issue?
➜ conjurops-jenkins git:(master) ✗ chef exec "bundle exec ruby -e \"require 'berkshelf'\""
-e:1:in `require': cannot load such file -- berkshelf (LoadError)
from -e:1:in `<main>'
vs
chef exec "ruby -e \"require 'berkshelf'\""
The 2nd one works fine, and I'm using ChefDK's bundle.
➜ conjurops-jenkins git:(master) ✗ chef exec which bundle
/Users/dustin/.chefdk/gem/ruby/2.1.0/bin/bundle
When I remove the Gemfile from my repo, it starts working just fine.
➜ conjurops-jenkins git:(master) ✗ chef exec which bundle
/Users/dustin/.chefdk/gem/ruby/2.1.0/bin/bundle
That's definitely weird. It should point to the ChefDK installation first (/opt/chefdk
), e.g.
$ chef exec "which -a bundle"
/opt/chefdk/embedded/bin/bundle
/Users/mlafeldt/.gem/ruby/2.1.2/bin/bundle
Looks like you installed Bundler a second time inside the ChefDK?
I'm wondering what's inside /Users/dustin/.chefdk/gem/ruby
? Maybe removing it helps?
That does work, I was user-installing some gems and doing it with bundler screwed it up. I removed this and chef-runner works again. Thank you!
Awesome!
Failing with
I have Chef and Berkshelf installed as part of ChefDK. Is ChefDK supported?