# Chef, test-kitchen, vagrant and net-ssh fun

**URL:** <https://discourse.chef.io/t/chef-test-kitchen-vagrant-and-net-ssh-fun/3619>\
**Category:** Chef Infra (archive)\
**Created:** [February 13, 2013, 10:37pm UTC](https://discourse.chef.io/t/chef-test-kitchen-vagrant-and-net-ssh-fun/3619 "2013-02-13T22:37:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdunn](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jdunn/32/1800_2.png) [@jdunn](https://discourse.chef.io/u/jdunn)\
**Post date:** [February 13, 2013, 10:37pm UTC](https://discourse.chef.io/t/chef-test-kitchen-vagrant-and-net-ssh-fun/3619/1 "2013-02-13T22:37:10Z")

</div>

Well maybe “fun” isn’t quite the right word.

- I have Chef 10.22.0.
- I have test-kitchen 0.7.0.
- I installed Vagrant from Gems, because if I don’t, test-kitchen won’t  
find the Vagrant gems.
- I want to run test-kitchen under Vagrant. I get this:

$ kitchen test  
/Users/jdunn/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/rubygems/specification.rb:1637:in  
`raise\_if\_conflicts’: Unable to activate chef-10.22.0, because  
net-ssh-2.2.2 conflicts with net-ssh (~\> 2.6) (Gem::LoadError)

It looks like Chef depends on net-ssh 2.6, and vagrant depends on  
net-ssh-2.2.2. So kitchen won’t start.

Does anyone have a workaround for this conflict?

- Julian

---

<div class="post-metadata">

**Author:** ![AJ\_Christensen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/aj_christensen/32/525_2.png) [@AJ\_Christensen](https://discourse.chef.io/u/AJ_Christensen)\
**Post date:** [February 14, 2013, 3:55am UTC](https://discourse.chef.io/t/chef-test-kitchen-vagrant-and-net-ssh-fun/3619/2 "2013-02-14T03:55:06Z")

</div>

Use bundler

Cheers,

AJ

On 14 February 2013 11:37, Julian C. Dunn [jdunn@aquezada.com](mailto:jdunn@aquezada.com) wrote:

> Well maybe "fun" isn't quite the right word.
> 
> - I have Chef 10.22.0.
> - I have test-kitchen 0.7.0.
> - I installed Vagrant from Gems, because if I don't, test-kitchen won't find  
> the Vagrant gems.
> - I want to run test-kitchen under Vagrant. I get this:
> 
> $ kitchen test  
> /Users/jdunn/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/rubygems/specification.rb:1637:in  
> `raise\_if\_conflicts': Unable to activate chef-10.22.0, because net-ssh-2.2.2  
> conflicts with net-ssh (~\> 2.6) (Gem::LoadError)
> 
> It looks like Chef depends on net-ssh 2.6, and vagrant depends on  
> net-ssh-2.2.2. So kitchen won't start.
> 
> Does anyone have a workaround for this conflict?
> 
> - Julian

---

<div class="post-metadata">

**Author:** ![Cassiano\_Leal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cassiano_leal/32/86_2.png) [@Cassiano\_Leal](https://discourse.chef.io/u/Cassiano_Leal)\
**Post date:** [February 14, 2013, 12:04pm UTC](https://discourse.chef.io/t/chef-test-kitchen-vagrant-and-net-ssh-fun/3619/3 "2013-02-14T12:04:56Z")

</div>

I second bundler.

Another option would be using RVM and leveraging gemsets, but bundler is cleaner IMO.

- cassiano

On Thursday, February 14, 2013 at 01:55, AJ Christensen wrote:

> Use bundler
> 
> Cheers,
> 
> AJ
> 
> On 14 February 2013 11:37, Julian C. Dunn \<[jdunn@aquezada.com](mailto:jdunn@aquezada.com) ([mailto:jdunn@aquezada.com](mailto:jdunn@aquezada.com))\> wrote:
> 
> > Well maybe "fun" isn't quite the right word.
> > 
> > - I have Chef 10.22.0.
> > - I have test-kitchen 0.7.0.
> > - I installed Vagrant from Gems, because if I don't, test-kitchen won't find  
> > the Vagrant gems.
> > - I want to run test-kitchen under Vagrant. I get this:
> > 
> > $ kitchen test  
> > /Users/jdunn/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/rubygems/specification.rb:1637:in  
> > `raise\_if\_conflicts': Unable to activate chef-10.22.0, because net-ssh-2.2.2  
> > conflicts with net-ssh (~\> 2.6) (Gem::LoadError)
> > 
> > It looks like Chef depends on net-ssh 2.6, and vagrant depends on  
> > net-ssh-2.2.2. So kitchen won't start.
> > 
> > Does anyone have a workaround for this conflict?
> > 
> > - Julian

---

<div class="post-metadata">

**Author:** ![Erik\_Hollensbe1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/erik_hollensbe1/32/588_2.png) [@Erik\_Hollensbe1](https://discourse.chef.io/u/Erik_Hollensbe1)\
**Post date:** [February 14, 2013, 1:33pm UTC](https://discourse.chef.io/t/chef-test-kitchen-vagrant-and-net-ssh-fun/3619/4 "2013-02-14T13:33:18Z")

</div>

Bundler (and rubygems, but only secondary) is the problem here. There's a  
workaround for some situations at the end of this email, but requires  
changes to the code.

vagrant depends on net-ssh 2.2.2 (and an older version of net-scp) which  
conflicts with chef's dependency on newer versions of net-ssh. I already  
had a PR rejected by Mitchell to resolve this the day of the 10.20/11.2  
release, and I'll leave it there.

Bundler "works" with vagrant and chef in the same gemfile because it  
actually won't let you bundle versions of chef greater than 10.18 -- and  
unless told to use something newer will have no qualms lowering the version  
of chef to satisfy its dependencies. If you use 10.20 or later, bundling  
won't even work. If you're on 11, you're probably going to have a bad day.

This is bundler (and rubygems) doing the right thing from their  
perspective, it's just that vagrant and chef are at odds of which version  
of net-ssh they need.

Berks and Chef-Workflow have the same problem with each other, and with  
vagrant. Berks (and Librarian) depend on constrained versions of chef and  
c-w tries very hard NOT to force chef versions on the user, allowing them  
to tailor the Gemfile to select that themselves. c-w works around this for  
the berks case by making you install it as a separate dependency and  
executing it with Bundler.with\_clean\_env (which allows rubygems to deal  
with the dependencies independently of Bundler). Since it runs berks as a  
command line tool, this works.

It still depends on vagrant as a library though (knife-server also has this  
issue but that's a little easier to deal with on a number of levels). If  
you use vagrant as a command line tool, you can get users to do the same  
thing for it as we do with berks/librarian in c-w, but they will have to  
install it independently.

On Thu, Feb 14, 2013 at 7:04 AM, Cassiano Leal [cassianoleal@gmail.com](mailto:cassianoleal@gmail.com)wrote:

> I second bundler.
> 
> Another option would be using RVM and leveraging gemsets, but bundler is  
> cleaner IMO.
> 
> - cassiano
> 
> On Thursday, February 14, 2013 at 01:55, AJ Christensen wrote:
> 
> Use bundler
> 
> Cheers,
> 
> AJ
> 
> On 14 February 2013 11:37, Julian C. Dunn [jdunn@aquezada.com](mailto:jdunn@aquezada.com) wrote:
> 
> Well maybe "fun" isn't quite the right word.
> 
> - I have Chef 10.22.0.
> - I have test-kitchen 0.7.0.
> - I installed Vagrant from Gems, because if I don't, test-kitchen won't  
> find  
> the Vagrant gems.
> - I want to run test-kitchen under Vagrant. I get this:
> 
> $ kitchen test
> 
> /Users/jdunn/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/rubygems/specification.rb:1637:in  
> `raise\_if\_conflicts': Unable to activate chef-10.22.0, because  
> net-ssh-2.2.2  
> conflicts with net-ssh (~\> 2.6) (Gem::LoadError)
> 
> It looks like Chef depends on net-ssh 2.6, and vagrant depends on  
> net-ssh-2.2.2. So kitchen won't start.
> 
> Does anyone have a workaround for this conflict?
> 
> - Julian

---

<div class="post-metadata">

**Author:** ![jdunn](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jdunn/32/1800_2.png) [@jdunn](https://discourse.chef.io/u/jdunn)\
**Post date:** [February 14, 2013, 3:08pm UTC](https://discourse.chef.io/t/chef-test-kitchen-vagrant-and-net-ssh-fun/3619/5 "2013-02-14T15:08:08Z")

</div>

On Thu, Feb 14, 2013 at 8:33 AM, Erik Hollensbe [erik@hollensbe.org](mailto:erik@hollensbe.org) wrote:

Bundler (and rubygems, but only secondary) is the problem here. There's a

> workaround for some situations at the end of this email, but requires  
> changes to the code.
> 
> vagrant depends on net-ssh 2.2.2 (and an older version of net-scp) which  
> conflicts with chef's dependency on newer versions of net-ssh. I already  
> had a PR rejected by Mitchell to resolve this the day of the 10.20/11.2  
> release, and I'll leave it there.

That's interesting -- I put in a PR  
[Relax pinning of net-ssh to ~\> 2.6.5 for compatibility with Chef 10.22.0 by juliandunn · Pull Request #1376 · hashicorp/vagrant · GitHub](https://github.com/mitchellh/vagrant/pull/1376) to relax the constraint, so  
we'll see what happens. I tested vagrant with 2.6.5 and it works fine.

I personally hate Bundler and try not to use it unless necessary. Bundler,  
gemsets, Omnibus Ruby installs, etc. -- all these things are just crutches  
for people's gems not to play nicely with each other and respect SemVer,  
etc. I feel a blog post coming on... 🙂

- Julian
