chef-boneyard / chef-dk

DEPRECATED: A streamlined development and deployment workflow for Chef Infra platform.
Apache License 2.0
380 stars 170 forks source link

Using InSpec in 'kitchen verify' fails due to net-ssh gem constraint conflicts. #668

Closed jzohrab closed 8 years ago

jzohrab commented 8 years ago

With the Chef Development Kit Version 0.10.0 and inspec set as the .kitchen.yml verifier, kitchen verify fails with the below:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #verify action: [Unable to activate specinfra-2.43.9, because net-ssh-3.0.2 conflicts with net-ssh (~> 2.7)]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Ruby version: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin13]

Some gems I have installed:

$ gem list | grep spec ... and edited a bit
chefspec (4.4.0)
inspec (0.9.10, 0.9.9)
kitchen-inspec (0.10.1)
rspec (3.4.0, 3.3.0, 2.11.0)
serverspec (2.24.1)
specinfra (2.43.9)

$ gem list | grep net-ssh
net-ssh (3.0.2, 2.9.4, 2.9.2, 2.9.1)

The .kitchen/logs/ubuntu log had the following:

Note: for readability, have removed some long lines, replace tokens:

KITCHEN_INSTANCE = /Users/jzohrab/.rvm/gems/ruby-2.2.0/gems/test-kitchen-1.5.0/lib/kitchen/instance.rb
INSPEC_PATH = /Users/jzohrab/.rvm/gems/ruby-2.2.0/gems/inspec-0.9.10/lib/inspec
GEMS_PATH = /Users/jzohrab/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems

ubuntu: -----> Verifying <default-ubuntu-1404>...
ubuntu: Verify failed on instance <default-ubuntu-1404>.
ubuntu: ------Exception-------
ubuntu: Class: Gem::ConflictError
ubuntu: Message: Unable to activate specinfra-2.43.9, because net-ssh-3.0.2 conflicts with net-ssh (~> 2.7)
ubuntu: ------Backtrace-------
ubuntu: $GEMS_PATH/specification.rb:2112:in `raise_if_conflicts'
ubuntu: $GEMS_PATH/specification.rb:1280:in `activate'
ubuntu: $GEMS_PATH/specification.rb:1314:in `block in activate_dependencies'
ubuntu: $GEMS_PATH/specification.rb:1300:in `each'
ubuntu: $GEMS_PATH/specification.rb:1300:in `activate_dependencies'
ubuntu: $GEMS_PATH/specification.rb:1282:in `activate'
ubuntu: /Users/jzohrab/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems.rb:198:in `rescue in try_activate'
ubuntu: /Users/jzohrab/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems.rb:195:in `try_activate'
ubuntu: $GEMS_PATH/core_ext/kernel_require.rb:126:in `rescue in require'
ubuntu: $GEMS_PATH/core_ext/kernel_require.rb:39:in `require'
ubuntu: /Users/jzohrab/Documents/Projects/chef_tutorial/chef-repo/cookbooks/InSpecDemo/test/integration/helpers/serverspec/spec_helper.rb:1:in `load'
ubuntu: $INSPEC_PATH/profile_context.rb:34:in `instance_eval'
ubuntu: $INSPEC_PATH/profile_context.rb:34:in `load'
ubuntu: $INSPEC_PATH/runner.rb:101:in `add_content'
ubuntu: $INSPEC_PATH/runner.rb:81:in `block in add_tests'
ubuntu: $INSPEC_PATH/runner.rb:80:in `each'
ubuntu: $INSPEC_PATH/runner.rb:80:in `add_tests'
ubuntu: /Users/jzohrab/.rvm/gems/ruby-2.2.0/gems/kitchen-inspec-0.10.1/lib/kitchen/verifier/inspec.rb:41:in `call'
ubuntu: $KITCHEN_INSTANCE:405:in `block in verify_action'
ubuntu: $KITCHEN_INSTANCE:495:in `call'
ubuntu: $KITCHEN_INSTANCE:495:in `synchronize_or_call'
ubuntu: $KITCHEN_INSTANCE:460:in `block in action'
ubuntu: /Users/jzohrab/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/benchmark.rb:288:in `measure'
ubuntu: $KITCHEN_INSTANCE:459:in `action'
ubuntu: $KITCHEN_INSTANCE:401:in `verify_action'
ubuntu: $KITCHEN_INSTANCE:348:in `block in transition_to'
ubuntu: $KITCHEN_INSTANCE:347:in `each'
ubuntu: $KITCHEN_INSTANCE:347:in `transition_to'
ubuntu: $KITCHEN_INSTANCE:160:in `verify'
ubuntu: /Users/jzohrab/.rvm/gems/ruby-2.2.0/gems/test-kitchen-1.5.0/lib/kitchen/command.rb:176:in `public_send'
ubuntu: /Users/jzohrab/.rvm/gems/ruby-2.2.0/gems/test-kitchen-1.5.0/lib/kitchen/command.rb:176:in `block (2 levels) in run_action'
ubuntu: ----------------------
jzohrab commented 8 years ago

Working through this and will post notes as I go, rather than at the end in a nice neat report. Will clean up the comments in here when I get everything worked out, maybe.

Upgrading specinfra to latest version (gem install specinfra -v 2.50.4), which uses updated net-ssh gem, gives a different error:

Message: Failed to complete #verify action: [undefined local variable or method `failure_slash_error_line' for #<RSpec::Core::Formatters::ExceptionPresenter:0x007fab04936550>]

Ref https://twitter.com/kantrn/status/664913752832126976 for a tweet on the above.

jzohrab commented 8 years ago

https://rubygems.org/gems/specinfra/versions/2.44.8 is the lowest number that changes the net-ssh ~> 2.7 dependency. It has dependency net-ssh < 3.1, >= 2.7, but unfortunately installing that gem also leads to the undefined local variable or method 'failure_slash_error_line' issue.

jzohrab commented 8 years ago

Submitted PR https://github.com/mizzy/serverspec/pull/553 to serverspec to deal with the error above.

charlesjohnson commented 8 years ago

This is verified working on ChefDK 0.15.15