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

knife-spork and chef_repo_path #133

Closed
lamont-granquist opened this issue Jul 27, 2014 · 24 comments
Closed

knife-spork and chef_repo_path #133

lamont-granquist opened this issue Jul 27, 2014 · 24 comments
Milestone

Comments

@lamont-granquist
Copy link
Contributor

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 jonlives added this to the Version 1.4.0 milestone Aug 1, 2014
@jonlives
Copy link
Owner

jonlives commented Aug 1, 2014

@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
Copy link
Contributor Author

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
Copy link
Owner

@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
Copy link
Contributor Author

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
Copy link
Owner

@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
Copy link
Contributor Author

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

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

ui.fatal "No default cookbook_path; Specify with -o or fix your knife.rb."

@lamont-granquist
Copy link
Contributor Author

And github loses posts when i back up...

@jonlives
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Owner

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

@lamont-granquist
Copy link
Contributor Author

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

@jonlives
Copy link
Owner

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

@lamont-granquist
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

👍

jonlives pushed a commit that referenced this issue Aug 19, 2014
@jonlives
Copy link
Owner

@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: 2ee8f2f

@lamont-granquist
Copy link
Contributor Author

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
Copy link
Owner

@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
Copy link
Contributor Author

Yeah, I think bundler is drunk.

@lamont-granquist
Copy link
Contributor Author

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

@lamont-granquist
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Owner

Released in 1.4.0

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

2 participants