Issue #22362 has been updated by Melissa Stone.

Status changed from Merged - Pending Release to Closed

Released in Puppet 3.4.0-rc1

----------------------------------------
Bug #22362: Changes in const_defined?() on ruby 1.9 break Puppet::Util::Classgen
https://projects.puppetlabs.com/issues/22362#change-100376

* Author: Paweł Tomulik
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: ruby19
* Target version: 3.4.0
* Affected Puppet version: 
* Keywords: const_defined? ruby 1.9 1.8 classgen :parent Puppet::Type 
inheritance
* Branch: https://github.com/puppetlabs/puppet/pull/1864
----------------------------------------
I have this example:

    #lib/puppet/type/packagex.rb
    module Puppet
      newtype(:packagex, :parent => Puppet::Type.type(:package)) do
      end
    end

    # lib/puppet/provider/packagex/ports.rb
    Puppet::Type.type(:packagex).provide :ports, 
      :parent => Puppet::Type.type(:package).provider(:ports) do
    end

    # test.rb
    $LOAD_PATH.unshift('/var/puppet/lib')
    require 'puppet'
    Puppet::Type.type(:packagex)

Running 'ruby test.rb' fails on ruby >=1.9 with the following exception:

    /usr/local/lib/ruby/site_ruby/1.9/puppet/util/autoload.rb:68:in `rescue in 
load_file': Could not autoload puppet/type/packagex: Could not autoload 
puppet/provider/packagex/ports: constant Puppet::Type::Packagex::ProviderPorts 
not defined (Puppet::Error)
            from 
/usr/local/lib/ruby/site_ruby/1.9/puppet/util/autoload.rb:59:in `load_file'
            from 
/usr/local/lib/ruby/site_ruby/1.9/puppet/util/autoload.rb:201:in `load'
            from 
/usr/local/lib/ruby/site_ruby/1.9/puppet/metatype/manager.rb:159:in `type'
            from /tmp/test.rb:4:in `<main>'

The problem appears, when using `newtype` with `:parent` argument. I've tracked 
down the problem and found that the exception is raised from 
`Puppet::Util::Classgen.rmclass()`. The method uses `const_defined?()` whose 
behavior [changed in ruby 
1.9](http://makandracards.com/makandra/14699-module-const_defined-behaves-differently-in-ruby-1-9-and-ruby-1-8).
 I've already fix for this and will create PR on github.
    



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to