jonlives / knife-spork

A workflow plugin to help many devs work with cookbooks and environments at once
Other
335 stars 97 forks source link

knife-spork and chef_repo_path #133

Closed lamont-granquist closed 10 years ago

lamont-granquist commented 10 years ago
FATAL: No default cookbook_path; Specify with -o or fix your knife.rb.

I've got a chef_repo_path set, and Chef::Config should derive cookbook_path from that setting, so I'm fairly confused as to why knife-spork can't find cookbook_path.

It also clearly seems to assume that environment_path must be an array, when it can also be a string:

ERROR: knife encountered an unexpected error
This may be a bug in the 'spork bump' knife command or plugin
Please collect the output of this command with the `-VV` option before filing a bug report.
Exception: NoMethodError: undefined method `first' for "/Users/lamont/env/sk/chef-repo/environments":String
jonlives commented 10 years ago

@lamont-granquist thanks for the bug report - I'm away for the next week but will be starting work on the next release when I return - I'll dig into this then & have added this to that milestone. Spork support passing paths in a variety of places, and it seems like one of them (or more specifically, how I coded that behaviour) is breaking this.

lamont-granquist commented 10 years ago

Yeah, I haven't had time to look at it either. I just rolled back to old config since I didn't have time to stop and fix. Berkshelf had an issue as well, jamie only just pushed a fix a couple days go. Generally now all the directory config stuff can be an array or a string, and all the derived cases can be driven off of the single chef_repo_path

jonlives commented 10 years ago

@lamont-granquist just digging into this now - what version of chef-client did you have installed when you saw this? Could I also please have the -VV output of the command which produced this error?

lamont-granquist commented 10 years ago

Probably 12.0.0.alpha.1...

Well this is odd, there's no stack dump with -VV:

% knife spork bump sk_role_base -VV
FATAL: No default cookbook_path; Specify with -o or fix your knife.rb.
USAGE: knife spork bump COOKBOOK [major|minor|patch|manual]
    -s, --server-url URL             Chef Server URL
        --chef-zero-host HOST        Host to start chef-zero on
        --chef-zero-port PORT        Port (or port range) to start chef-zero on.  Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works.
    -k, --key KEY                    API Client Key
        --[no-]color                 Use colored output, defaults to false on Windows, true otherwise
    -c, --config CONFIG              The configuration file to use
    -o, --cookbook-path PATH:PATH    A colon-separated path to look for cookbooks in
        --defaults                   Accept default values for all questions
    -d, --disable-editing            Do not open EDITOR, just accept the data as is
    -e, --editor EDITOR              Set the editor to use for interactive commands
    -E, --environment ENVIRONMENT    Set the Chef environment (except for in searches, where this will be flagrantly ignored)
    -F, --format FORMAT              Which format to use for output
    -z, --local-mode                 Point knife commands at local repository instead of server
    -u, --user USER                  API Client Username
        --print-after                Show the data after a destructive operation
    -V, --verbose                    More verbose output. Use twice for max verbosity
    -v, --version                    Show chef version
    -y, --yes                        Say yes to all prompts for confirmation
    -h, --help                       Show this message
jonlives commented 10 years ago

@lamont-granquist hmm - that is odd. Can you verify that this only happens with 12.x and not the latest stable 11.x release? Just to narrow down where I go digging :p

lamont-granquist commented 10 years ago

Well, it was probably off master, but I replicated with 11.14.2.

-VV isn't giving me a stacktrace, but its coming from:

https://github.com/jonlives/knife-spork/blob/faa91f9a69f665884de8bfc2658582f5c86fc519/lib/knife-spork/runner.rb#L275

lamont-granquist commented 10 years ago

And github loses posts when i back up...

jonlives commented 10 years ago

Awsome, thanks for the info - I'll take a look! Hoping to get this out in the next release, this week most likely.

lamont-granquist commented 10 years ago

weird.

pp config[:cookbook_path] results in "/Users/lamont/env/sk/chef-repo/cookbooks", but config.has_key?(:cookbook_path) is false.

it looks like mixlib-shellout is not setting has_key? to true when the config value is set to a default value or something?

jonlives commented 10 years ago

This is gonna be one of them fun ones, I can just tell :p

lamont-granquist commented 10 years ago

Well I think you can change it to test for .nil? or something like that and work around mixlib-shellout's behavior...

jonlives commented 10 years ago

That sounds like a plan - gonna poke at this tomorrow and will try that first.

lamont-granquist commented 10 years ago

So the next problem after that is that it can be a string instead of an array:

% knife spork bump sk_role_base -VV
"/Users/lamont/env/sk/chef-repo/cookbooks"
/Users/lamont/.rvm/gems/ruby-2.1.2/gems/knife-spork-1.3.4/lib/knife-spork/runner.rb:138:in `environment_path': undefined method `first' for "/Users/lamont/env/sk/chef-repo/environments":String (NoMethodError)
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/knife-spork-1.3.4/lib/knife-spork/runner.rb:46:in `run_plugins'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/knife-spork-1.3.4/lib/chef/knife/spork-bump.rb:48:in `run'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/knife.rb:493:in `block in run_with_pretty_exceptions'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/local_mode.rb:38:in `with_server_connectivity'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/knife.rb:492:in `run_with_pretty_exceptions'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/knife.rb:175:in `run'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/application/knife.rb:139:in `run'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/bin/knife:25:in `<top (required)>'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/bin/knife:23:in `load'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/bin/knife:23:in `<main>'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
lamont-granquist commented 10 years ago

And then if I make that an array it also wants environment_path to be an Array:

% knife spork bump sk_role_base -VV
["/Users/lamont/env/sk/chef-repo/cookbooks"]
/Users/lamont/.rvm/gems/ruby-2.1.2/gems/knife-spork-1.3.4/lib/knife-spork/runner.rb:138:in `environment_path': undefined method `first' for "/Users/lamont/env/sk/chef-repo/environments":String (NoMethodError)
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/knife-spork-1.3.4/lib/knife-spork/runner.rb:46:in `run_plugins'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/knife-spork-1.3.4/lib/chef/knife/spork-bump.rb:48:in `run'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/knife.rb:493:in `block in run_with_pretty_exceptions'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/local_mode.rb:38:in `with_server_connectivity'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/knife.rb:492:in `run_with_pretty_exceptions'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/knife.rb:175:in `run'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/lib/chef/application/knife.rb:139:in `run'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/gems/chef-12.0.0.alpha.0/bin/knife:25:in `<top (required)>'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/bin/knife:23:in `load'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/bin/knife:23:in `<main>'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/lamont/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
jonlives commented 10 years ago

Aha - good spot. I think I'm going to go through everywhere I'm parsing config paths etc and make sure they're handling all the cases they should be. I'll include fixing that here too :)

lamont-granquist commented 10 years ago

:+1:

jonlives commented 10 years ago

@lamont-granquist could I get you to try out https://github.com/jonlives/knife-spork/releases/tag/1.4.0.beta.1 please, and see if it fixes the issue for you? It's built from the 1.4.0 branch, this being the relevant commit: https://github.com/jonlives/knife-spork/commit/2ee8f2f8947d32c5c5f047d5adbe328e56a812ef

lamont-granquist commented 10 years ago

So, "Using knife-spork 1.3.4 from git://github.com/jonlives/knife-spork.git (at 1.4.0.beta.1)"

Still getting this:

% knife spork bump sk_role_base -VV
FATAL: No default cookbook_path; Specify with -o or fix your knife.rb.
USAGE: knife spork bump COOKBOOK [major|minor|patch|manual]
    -s, --server-url URL             Chef Server URL
[...etc...]
jonlives commented 10 years ago

@lamont-granquist could I please just check that you installed the 1.4.0.1.beta.1 gem from the page I linked? Just cos you mentioned 1.3.4 above...if you are, I'll need to take another look at what mixlib-shellout's doing, cos that beta release is doing this now: https://github.com/jonlives/knife-spork/blob/1.4.0/lib/knife-spork/runner.rb#L286

lamont-granquist commented 10 years ago

Yeah, I think bundler is drunk.

lamont-granquist commented 10 years ago

I need more coffee and it would help if my cable modem stopped rebooting every 5 mins...

lamont-granquist commented 10 years ago

So, I don't think that commit is in the 1.4.0.beta.1 tag.... Yeah, just using "1.4.0" works a lot better..

% knife spork bump sk_role_base -VV
Successfully bumped sk_role_base to v0.0.20!

:shipit:

jonlives commented 10 years ago

Ah I may have tagged before pushing to the remote branch or something. It was a coffee-lacking day here too. Excellent, glad that works. I'll get it out in the 1.4.0 release.

jonlives commented 10 years ago

Released in 1.4.0