Why does puppet keeps telling me: "Puppet.features.rubygems? is deprecated. Require rubygems in your application's entry point if you need it"?

growse asked:

I’ve got a reasonably small (~10 hosts) puppet installation, and recently, I’ve started to get warning messages on every puppet agent run. The message is:

Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in /etc/puppet/modules/firewall/lib/facter/iptables.rb
Info: Loading facts in /etc/puppet/modules/concat/lib/facter/concat_basedir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/iptables.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Debug: catalog supports formats: b64_zlib_yaml dot pson raw yaml; using pson
Warning: Puppet.features.rubygems? is deprecated. Require rubygems in your application's entry point if you need it.
   (at /usr/lib/ruby/vendor_ruby/puppet/util/feature.rb:17:in `add')
Info: Caching catalog for hostname.example.com

I’m not 100% sure what changed – this is only a test environment, so we’re not quite as strict about change management as we should be. It could be that a new puppet package was installed, or an extra module added – we don’t know.

The problem is, I’ve no information to go on regarding what could be causing this. Grepping through my /etc/puppet/modules folder reveals a bunch of modules that use rubygems.

What’s causing this warning, and how do I fix it?

My answer:


This is by design as of Puppet 3.0.1.

If bundler is loaded, e.g. bundler exec puppet, then don’t load
rubygems, since bundler has its own logic for managing gems in the
current application environment. And the set of gems, versions, etc is
often different than what gems you may have installed, via rvm for
example.

If bundler is not loaded, fall back on the old behavior, which is to
ensure rubygems is loaded before calling any puppet code. Ideally,
this should be done in the bin/puppet script, however, that doesn’t
work for rack setups, so we moved rubygems loading to the command line
code, which is effectively the puppet application entry point.

Several features, e.g. stomp, were calling Puppet.features.rubygems?
only for its side-effect of loading rubygems before evaluating the
calling feature’s gems. This is no longer necessary now that we ensure
the gem loading system is sane early on.

Custom features may be calling Puppet.features.rubygems?, so we’ve
added a deprecation warning and preserved the old behavior (of
explicitly requiring rubygems). It may be necessary to modify custom
features in order to ensure puppet works correctly in a bundler
environment.

If you’ve updated your puppetmaster to 3.0.1, you should update all your puppet agents as well. Or vice-versa.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.