Chefspec and Berkshelf Gem Dependency Duel

I was trying to get some custom matchers for an LWRP in one of my Chef library cookbooks to be recognized in the wrapper cookbook I was writing chefspec tests for. I was on chefspec 3.0.2 and found this which made me think I should upgrade, so upgrade I did to 3.1.4. Along with it, the i18n gem was also upgraded to 0.6.9 due to this issue.

So what? Well, berkshelf has a dependency on activesupport (~> 3.2.0), of which I had activesupport 3.2.13 and it required i18n 0.6.1. The first thing I saw was

$ rspec spec/recipes/default_spec.rb
/opt/local/lib/ruby1.9/gems/1.9.1/gems/chefspec-3.1.4/lib/chefspec/berkshelf.rb:4:in `rescue in ': I could not load the Berkshelf gem! You must have Berkshelf installed on your local system before you can use the `berkshelf' plugin. You can install berkshelf by running `gem install berkshelf', or add Berkshelf to your Gemfile and run the `bundle' command to install. (ChefSpec::Error::GemLoadError)

I tried just installing the lastest activesupport with gem install activesupport, which installed 4.0.2. Unfortunately, that didn’t satisfy berkshelf’s dependency. After some frustration, I listed all of the versions of activesupport available.

$ gem list activesupport --remote --all

*** REMOTE GEMS ***

activesupport (4.0.2, 4.0.1, 4.0.0, 3.2.16, 3.2.15, 3.2.14, 3.2.13, 3.2.12, 3.2.11, 3.2.10, 3.2.9, 3.2.8, 3.2.7, 3.2.6, 3.2.5, 3.2.4, 3.2.3, 3.2.2, 3.2.1, 3.2.0, 3.1.12, 3.1.11, 3.1.10, 3.1.9, 3.1.8, 3.1.7, 3.1.6, 3.1.5, 3.1.4, 3.1.3, 3.1.2, 3.1.1, 3.1.0, 3.0.20, 3.0.19, 3.0.18, 3.0.17, 3.0.16, 3.0.15, 3.0.14, 3.0.13, 3.0.12, 3.0.11, 3.0.10, 3.0.9, 3.0.8, 3.0.7, 3.0.6, 3.0.5, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0, 2.3.18, 2.3.17, 2.3.16, 2.3.15, 2.3.14, 2.3.12, 2.3.11, 2.3.10, 2.3.9, 2.3.8, 2.3.7, 2.3.6, 2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.3, 2.2.2, 2.1.2, 2.1.1, 2.1.0, 2.0.5, 2.0.4, 2.0.2, 2.0.1, 2.0.0, 1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4.0, 1.3.1, 1.3.0, 1.2.5, 1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.1.1, 1.1.0, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0)
...

Based on that, I ended up installing activesupport 3.2.16. It was happy with i18n 0.6.9 and chefspec had no problem loading berkshelf. Now, my custom matchers in my library cookbook are recognized in my wrapper cookbook’s chefspec tests and all is right with the world.

Leave a Reply

Your email address will not be published. Required fields are marked *