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


#1

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

#2

Use bundler

Cheers,

AJ

On 14 February 2013 11:37, Julian C. Dunn 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

#3

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

#4

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.comwrote:

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 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

#5

On Thu, Feb 14, 2013 at 8:33 AM, Erik Hollensbe 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
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… :slight_smile:

  • Julian