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

puppet 7 gem is missing runtime dependency on scanf

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 7.0.0
    • Fix Version/s: PUP 7.1.0
    • Component/s: None
    • Template:
      PUP Bug Template
    • Team:
      Coremunity
    • Sprint:
      Platform Core KANBAN
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      The puppet gem now depends on scanf which is necessary when running on ruby 2.7. This makes it possible to run module tests against the puppet gem on ruby 2.7.
    • QA Risk Assessment:
      Needs Assessment

      Description

      Ruby 2.7 removed the scanf implementation (in Kernel, IO and String) from core ruby to a separate gem. Puppet's scanf function depends on that ruby method, but only expresses the scanf runtime dependency in its Gemfile, but not in the gem that is pushed to rubygems. See https://rubygems.org/gems/puppet/versions/7.0.0.

      As a result, if a module calls the puppet scanf function using puppet 7 (gem) and ruby 2.7, such as when running rspec tests, then you'll see (for example in https://github.com/puppetlabs/puppetlabs-puppetdb/pull/317)

             LoadError:
               cannot load such file -- scanf
      

      This doesn't affect module functionality when testing or running against puppet-agent 7 packages, because the scanf gem is included.

      AFAIK rubygems doesn't have a way to express conditional runtime dependencies (i.e. only add this dependency when running on ruby 2.7 and up). So the best thing may be to always add the runtime dependency for the puppet 7.x collection? If you're running the puppet 7 gem with ruby 2.5.0, then things will still work (the scanf gem is ignored).

      $ rbenv shell 2.5.8
      $ gem install scanf --no-document
      Fetching: scanf-1.0.0.gem (100%)
      Successfully installed scanf-1.0.0
      1 gem installed
      $ irb
      irb(main):001:0> require 'scanf'
      => true
      irb(main):002:0> $LOADED_FEATURES.grep /scanf/
      => ["/usr/local/Cellar/rbenv/1.1.2/versions/2.5.8/lib/ruby/2.5.0/scanf.rb"]
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support