Can I make my entire module "depend" on rubygems being installed?

31 views
Skip to first unread message

R. Tyler Croy

unread,
Apr 19, 2014, 9:52:15 PM4/19/14
to puppe...@googlegroups.com
I'm trying to write a custom package provider which depends on a
specific rubygems being present, if I try to confine my provider to the
"rubygems" feature, I get this error:

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')
Failed to load feature test for rubygems: no such file to load -- rubygems

If I remove that "confine" then things explode since `rubygems` the
package isn't installed.

I tried making Package['rubygems'] a requirement of pulling my package
in, e.g.

class {
"jenkins":
require => Package['rubygems'];
}

But, because I'm automatically pulling some things in for installing the
Jenkins package, I end up with a dependency cycle:


Error: Could not apply complete catalog: Found 1 dependency cycle:
(Anchor[apt::key D50582E6 present] => Apt::Key[Add key: D50582E6 from
Apt::Source jenkins] => File[jenkins.list] => Exec[apt_update] =>
Class[Apt::Update] => Anchor[apt::update] => Class[Apt] =>
Package[rubygems] => Class[Jenkins] => Anchor[jenkins::begin] =>
Class[Jenkins::Repo] => Anchor[jenkins::repo::begin] =>
Class[Jenkins::Repo::Debian] => Apt::Source[jenkins] =>
File[jenkins.list]) Try the '--graph' option and opening the resulting
'.dot' file in OmniGraffle or GraphViz


Is there a good reference I could follow, or example of how to make a
custom provider depend on Rubygems being installed without anything too
hacky?

Felix Frank

unread,
Apr 20, 2014, 2:49:21 PM4/20/14
to puppe...@googlegroups.com
On 04/20/2014 03:52 AM, R. Tyler Croy wrote:
> 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')
> Failed to load feature test for rubygems: no such file to load --
> rubygems

Hi,

I'm not sure about the whole context, but reading this error gives me
the idea that you're simply supposed to

require 'rubygems'

and just let the type/provider's initialization fail if it's not present.

HTH,
Felix

R. Tyler Croy

unread,
Apr 21, 2014, 1:25:25 PM4/21/14
to puppe...@googlegroups.com
Requiring rubygems will fail because it's not installed on the system,
that's where the dependency cycle comes into play. I cannot require the
Package[rubygems] -> Class[jenkins] safely because the Jenkins module
does some futzing about with Apt and apt::source :/


John Bollinger

unread,
Apr 22, 2014, 3:53:18 PM4/22/14
to puppe...@googlegroups.com


Connect the dots for me.  Why is it necessary for Package['rubygems'] to be applied before Class['jenkins']?  For what type are you trying to provide?

If the provider you are writing is for some resource type that Class['jenkins'] uses, then your best alternative may be to modify the jenkins module to express the relationship on some appropriate class or resource within.  Or you could perhaps do that without directly modifying the module, for instance with something along these lines:

My_resource_type<| |> {
  require +> [Package['rubygems']]
}


John

Reply all
Reply to author
Forward
0 new messages