Fix build_depends for Ruby 2.2
tedwardd opened this issue · 2 comments
Fedora 23 ships with ruby 2.2 by default. Puppet 3 is not compatible with ruby 2.2, only Puppet 4 will work. If I'm reading through the past issues correctly, the version of puppet libs shipped with fpm-cookery are from Puppet 3 which I believe is what is causing the following issue when trying to process build_depends:
WARNING: Unable to load Puppet. Automatic dependency installation disabled.
Is there any possibility of using the system puppet or possibly providing a way to define in the recipe.rb which version of puppet we need?
In the meantime, the only feasible workaround I can think of would be to use something like rvm to install and use an older version of ruby inside of my docker container but I'd prefer to avoid this if possible.
EDIT: After some testing, I was unable to get it working with rvm like I had thought I could. The only work around I've found is to use sh(dnf install #[packages]) which make the recipe now only work on Fedora (or other systems with DNF installed).
@k4k -- the code that loads the various Puppet modules is in dependency_inspector.rb (snippet from tag v0.32.0
):
begin
require 'puppet'
require 'puppet/resource'
require 'puppet/transaction/report'
# Init Puppet before using it
Puppet.initialize_settings
rescue Exception
end
What happens if you try to run this code from a REPL (irb
, pry
, etc.)?
Ran into this issue today as well in Ruby 2.3. The output I get from the above is:
irb(main):001:0> require 'puppet'
WARN: Unresolved specs during Gem::Specification.reset:
json_pure (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
NameError: uninitialized constant Syck
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/puppet-3.8.7/lib/puppet/vendor/safe_yaml/lib/safe_yaml/syck_node_monkeypatch.rb:42:in `<top (required)>'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/puppet-3.8.7/lib/puppet/vendor/safe_yaml/lib/safe_yaml.rb:197:in `<module:YAML>'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/puppet-3.8.7/lib/puppet/vendor/safe_yaml/lib/safe_yaml.rb:132:in `<top (required)>'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/puppet-3.8.7/lib/puppet/vendor/require_vendored.rb:4:in `<top (required)>'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/puppet-3.8.7/lib/puppet/vendor.rb:40:in `require_libs'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/puppet-3.8.7/lib/puppet/vendor.rb:53:in `load_vendored'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/puppet-3.8.7/lib/puppet.rb:174:in `<module:Puppet>'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/puppet-3.8.7/lib/puppet.rb:29:in `<top (required)>'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `require'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
from /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from (irb):1
from /opt/chef/embedded/bin/irb:11:in `<main>'
Made a brief attempt to run fpm-cook with Puppet 4, but looks like Hiera's been changed enough to not work as a drop-in replacement.
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/hiera-3.2.1/lib/hiera/util.rb:56:in `split_key': undefined method `split' for :arch:Symbol (NoMethodError)
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/hiera-3.2.1/lib/hiera/backend.rb:253:in `lookup'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/hiera-3.2.1/lib/hiera.rb:116:in `lookup'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/fpm-cookery-0.32.0/lib/fpm/cookery/hiera.rb:29:in `lookup'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/fpm-cookery-0.32.0/lib/fpm/cookery/recipe.rb:233:in `applicator'
from /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/fpm-cookery-0.32.0/lib/fpm/cookery/recipe.rb:208:in `block in apply'