Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-10390

Ruby file gets loaded twice

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • None
    • PUP 6.15.0
    • None
    • Night's Watch
    • 3
    • NW - 2020-04-15
    • Bug Fix
    • The 'gem' package provider's ruby file was getting loaded twice and causing undesired warnings at each puppet run. This was happening due to an unnecessary file requirement which is now removed.
    • Needs Assessment

    Description

      The provider/package/gem.rb file gets loaded twice. This prevents us from having constant variables without getting the following warnings at each run:
      /Users/luchi/repos/puppet/lib/puppet/provider/package/gem.rb:21: warning: already initialized constant MY_CONSTANT_VARIABLE
      /Users/luchi/repos/puppet/lib/puppet/provider/package/gem.rb:21: warning: previous definition of MY_CONSTANT_VARIABLE was here

      This happens due to the require done in provider/package/puppet_gem.rb and then loaded again in util/autoload.rb. This can be seen by putting a 'puts(caller)' in provider/package/gem.rb.

      After fixing the issue, a refactoring should be done in provider/package/gem.rb to use (for better code readability):

      GEM_VERSION = Puppet::Util::Package::Version::Gem
      GEM_VERSION_RANGE = Puppet::Util::Package::Version::Range

      Attachments

        Issue Links

          Activity

            People

              luchian.nemes Luchian Nemes
              luchian.nemes Luchian Nemes
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support