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

Puppet::Util::Windows is undefined on non-Windows platforms

    XMLWordPrintable

Details

    • Phoenix
    • 1
    • Phoenix 2022-03-16
    • Needs Assessment
    • 47102
    • 1
    • Bug Fix
    • Fixes a bug that prevented pdk unit tests from working when trying to test a resource with a Windows provider, such as "service" resources.
    • Needs Assessment

    Description

      The file lib/puppet/util/windows.rb defines a set of constants that should be available on all platforms, such as Puppet::Util::Windows, Puppet::Util::Windows::Service and Puppet::Util::Windows::Service::DEFAULT_TIMEOUT.

      It also requires Windows-specific code that is only safe to load on Windows, because the code tries to load native libraries, such as user32.dll.

      The problem is when puppet is running on a non-Windows platform, then lib/puppet/util/windows.rb is never loaded. As a result, trying to test a service resource using rspec-puppet fails when trying to reference the Puppet::Util::Windows constant. See PDK-1760 for steps to reproduce.

      A quicker reproduction is:

      $ bundle exec ruby -e "require 'puppet'; puts Puppet::Util::Windows"
      Traceback (most recent call last):
      -e:1:in `<main>': uninitialized constant Puppet::Util::Windows (NameError)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              josh Josh Cooper
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support