bmarini / knife-inspect

Inspect your chef repo as is compares to what is on your chef server
MIT License
55 stars 13 forks source link

Fixed Chef::Exceptions::InvalidCookbookVersion errors #35

Closed docwhat closed 9 years ago

docwhat commented 9 years ago

When using some chef .gems (such as 11.18.0) knife-inspect causes an except to be thrown.

This is because Chef::Version is only meant for cookbooks, not chef version numbers. For Chef version numbers, Gem::Version should be used.

Without this fix, I was getting errors for all knife commands:

/opt/chefdk/embedded/apps/chef/lib/chef/version_class.rb:65:in `parse': '11.18.0.rc.1' does not match 'x.y.z' or 'x.y' (Chef::Exceptions::InvalidCookbookVersion)
        from /opt/chefdk/embedded/apps/chef/lib/chef/version_class.rb:24:in `initialize'
        from /Users/docwhat/.chefdk/gem/ruby/2.1.0/gems/knife-inspect-0.11.0/lib/health_inspector/checklists/cookbooks.rb:4:in `new'
        from /Users/docwhat/.chefdk/gem/ruby/2.1.0/gems/knife-inspect-0.11.0/lib/health_inspector/checklists/cookbooks.rb:4:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /Users/docwhat/.chefdk/gem/ruby/2.1.0/gems/knife-inspect-0.11.0/lib/health_inspector.rb:8:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        from /Users/docwhat/.chefdk/gem/ruby/2.1.0/gems/knife-inspect-0.11.0/lib/chef/knife/cookbook_inspect.rb:2:in `<top (required)>'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:37:in `load'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:37:in `block in load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:37:in `each'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:37:in `load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:120:in `load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:168:in `run'
        from /opt/chefdk/embedded/apps/chef/lib/chef/application/knife.rb:139:in `run'
        from /opt/chefdk/embedded/apps/chef/bin/knife:25:in `<top (required)>'
        from /opt/chefdk/bin/knife:33:in `load'
        from /opt/chefdk/bin/knife:33:in `<main>'
gregkare commented 9 years ago

Nice catch, thanks!

I'm adding you to the list of contributors in the README, updating the HISTORY file and releasing a new version including this fix

gregkare commented 9 years ago

I've released version 0.11.1 including this fix.