test-kitchen / busser-serverspec

A Busser runner plugin for the serverspec testing library
Other
54 stars 41 forks source link

Bundler version in postinstall #53

Closed achamo closed 5 years ago

achamo commented 5 years ago

Hi,

I'm using busser and busser-serverspec with Chef 12.13.81 on CentOS 7. Since today, I'm facing this issue:

-----> Installing Busser (busser)
Fetching: thor-0.19.0.gem (100%)
       Successfully installed thor-0.19.0
Fetching: busser-0.7.1.gem (100%)
       Successfully installed busser-0.7.1
       2 gems installed
-----> Installing Busser plugin: busser-serverspec
       Plugin serverspec installed (version 0.5.10)
-----> Running postinstall for serverspec plugin
       /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:619:in `ensure_required_rubygems_version_met': bundler requires RubyGems version >= 3.0.0. Try 'gem update --system' to update RubyGems itself. (Gem::InstallError)
        from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:828:in `pre_install_checks'
        from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:279:in `install'
        from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/resolver/specification.rb:97:in `install'
        from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/request_set.rb:166:in `block in install'
        from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/request_set.rb:156:in `each'
        from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/request_set.rb:156:in `install'
        from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/dependency_installer.rb:405:in `install'
        from /tmp/verifier/gems/gems/busser-0.7.1/lib/busser/rubygems.rb:44:in `install_gem'
        from /tmp/verifier/gems/gems/busser-0.7.1/lib/busser/helpers.rb:57:in `install_gem'
        from /tmp/verifier/gems/gems/busser-serverspec-0.5.10/lib/busser/runner_plugin/serverspec.rb:28:in `block in <class:Serverspec>'

In this line https://github.com/test-kitchen/busser-serverspec/blob/master/lib/busser/runner_plugin/serverspec.rb#L28 busser-serverspec installs bundler at the last version. How can we pin a version for bundler ? I can't upgrade rubygems.

lzecca78 commented 5 years ago

Having the same issue of @achamo here. Should be perfect be able to ping bundler version, due to latest upgrade of bundler, quite every logic now should take in consideration the pinning of the version

joe4dev commented 5 years ago

same issue here causing my CI build failures

joe4dev commented 5 years ago

I get some more specific log output (but basically the same):

/opt/chef/embedded/lib/ruby/2.5.0/rubygems/installer.rb:629:in `ensure_required_rubygems_version_met': The last version of bundler (>= 0) to support your Ruby & RubyGems was 1.17.3. Try installing it with `gem install bundler -v 1.17.3` (Gem::RuntimeRequirementNotMetError)
  bundler requires RubyGems version >= 3.0.0. The current RubyGems version is 2.7.6. Try 'gem update --system' to update RubyGems itself.
  from /opt/chef/embedded/lib/ruby/2.5.0/rubygems/installer.rb:852:in `pre_install_checks'
joe4dev commented 5 years ago

Either pinning bundler or updating RubyGems before via 'gem update --system' should fix this issue.

wheresalice commented 5 years ago

This is because of today's release of bundler 2.0 which depends on rubygems > 3.0.0

We have tried running sudo /opt/chef/embedded/bin/gem update --system before running another kitchen verify, but this introduces another issue:

-----> Installing Busser (busser)
       ERROR:  While executing gem ... (OptionParser::InvalidOption)
           invalid option: --no-rdoc
       sudo: /tmp/verifier/bin/busser: command not found
lzecca78 commented 5 years ago

@WheresAlice yes, the new gem binary does not support --no-ri nor --no-rdoc option, that is something embedded in 99% of configurations. I use kitchen with puppet and i cannot move forward with the version of gem because of default puppet provider gem set in every gem install command the --no-ri --no-rdoc. Is really a mess.

joe4dev commented 5 years ago

Does this work instead here? install_gem('bundler', '1.17.3')

EDIT: or even install_gem('bundler', '~> 1.17')

Following the install_gem plugin hook from:

wheresalice commented 5 years ago

That change would almost certainly work for my use-case, with the older version of Ruby embedded in Chef. It may not work or may cause issues for people with newer versions of Ruby.

caarlos0 commented 5 years ago

any workarounds?

wheresalice commented 5 years ago

The work around we have put in place is to configure our docker images to use our local internal ruby gem repo which doesn't have the newer version of bundler yet. This obviously isn't a suitable workaround for everyone.

Going forward our workaround will be to migrate from serverspec to inspec. Which is a fairly straightforward migration, and comes with other benefits.

caarlos0 commented 5 years ago

I'm going for the inspec thing...

jmangs commented 5 years ago

I've verified that install_gem('bundler', '~> 1.17') works as a fix as @joe4dev mentioned above. You can do a variation like this to verify it works locally:

$ sudo sed -i "28s/install_gem('bundler')/install_gem('bundler', '~> 1.17')/" /tmp/verifier/gems/gems/busser-serverspec-0.5.10/lib/busser/runner_plugin/serverspec.rb

This works for me. I've opened a PR with the relevant change.

MarkRoddy commented 5 years ago

If anyone needs an immediate work around, it appears that a second invocation of kitchen verify ... isn't susceptible to the failed attempt to install Bundler. For the time being we're working around this by running the verify command twice and allowing the first invocation to fail. This is the Rake task we're using at the moment:

task :testkitchen, [:suite] do |_t, args|
  error = nil
  begin
    sh "kitchen converge #{args[:suite]}"
    sh "kitchen verify #{args[:suite]} || true"
    sh "kitchen verify #{args[:suite]}"
  rescue StandardError => e
    error = e
  ensure
    sh "kitchen destroy #{args[:suite]}"
    raise error unless error.nil?
  end
end
dthorsen commented 5 years ago

This PR should fix this issue for most folks: https://github.com/bundler/bundler/pull/6867

dthorsen commented 5 years ago

Bundler 2.0.1 has been released and my test-kitchen runs are succeeding now. Your mileage may vary depending on the ruby gem version you have. I am running chefdk 2.4.17 with kitchen 1.19.2 and it is now working. My gem version is 2.6.14

lzecca78 commented 5 years ago

@dthorsen , the bundler version 2.0.1 has been released in order to avoid those kind of problems: Relaxed RubyGems requirement to >= 2.5.0 (#6867). Thanks to this, now, everything is back to work.

achamo commented 5 years ago

Yep with the last bundler release, this issue is irrelevant.

jmangs commented 5 years ago

An unfortunate side-effect of the latest bundler release is that you will need to use Ruby 2.3.0 or greater which means Chef 11 support is basically broken:

-----> Running postinstall for serverspec plugin

       /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `ensure_required_ruby_version_met': bundler requires Ruby version >= 2.3.0. (Gem::InstallError)

At this point we're just going to force people to move to InSpec given how many Ruby dependency problems there are (we've patched other ones via test-kitchen but this one is in the post-install step which isn't easy to address).