{"record":{"id":"b5bf3bb55cd9a57a","repo":"puppetlabs/puppet","slug":"could-not-match-version-info-info","errorCode":null,"errorMessage":"Could not match version info '%{info}'","messagePattern":"Could not match version info '%(.+?)'","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/ports.rb","lineNumber":61,"sourceCode":"    match = Regexp.last_match(2)\n    info = Regexp.last_match(3)\n\n    unless pkgstuff =~ /^\\S+-([^-\\s]+)$/\n      raise Puppet::Error,\n            _(\"Could not match package info '%{pkgstuff}'\") % { pkgstuff: pkgstuff }\n    end\n\n    version = Regexp.last_match(1)\n\n    if match == \"=\" or match == \">\"\n      # we're up to date or more recent\n      return version\n    end\n\n    # Else, we need to be updated; we need to pull out the new version\n\n    unless info =~ /\\((\\w+) has (.+)\\)/\n      raise Puppet::Error,\n            _(\"Could not match version info '%{info}'\") % { info: info }\n    end\n\n    source = Regexp.last_match(1)\n    newversion = Regexp.last_match(2)\n\n    debug \"Newer version in #{source}\"\n    newversion\n  end\n\n  def query\n    # support portorigin_glob such as \"mail/postfix\"\n    name = self.name\n    if name =~ %r{/}\n      name = self.name.split(%r{/}).slice(1)\n    end\n    self.class.instances.each do |instance|\n      if instance.name == name","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/ports.rb#L43-L79","documentation":"Raised by the FreeBSD 'ports' provider's latest method when 'portversion -v' output cannot be parsed. After deciding the port needs updating (comparison char is not '=' or '>'), the trailing info field must match '\\((\\w+) has (.+)\\)'; when it does not, Puppet raises this error including the raw info text. It almost always means the portversion output format changed or the ports/pkgdb metadata is stale.","triggerScenarios":"A package resource with provider => ports and ensure => latest (any code path calling latest) where portversion reports '<' but the third output field lacks a '(<source> has <version>)' segment, e.g. output like 'portpkg-1.7_5 < needs updating (=> \\'newport/pkg\\')'. The regex at lib/puppet/provider/package/ports.rb:60 must match or the error fires.","commonSituations":"FreeBSD hosts where the ports tree was refreshed but the pkgdb was not rebuilt; portupgrade suite upgrades that changed portversion output formatting; port origins renamed or removed from the ports tree; mixed ports/pkgng systems.","solutions":["Run 'portversion -v <origin>' by hand and compare the trailing parenthesized text with the expected '(port has <version>)' form","Refresh metadata: 'portsnap fetch update' then rebuild the package database with 'pkgdb -aFu' so portversion emits current data","Migrate to the pkgng provider on FreeBSD 10+; the portupgrade tooling this provider wraps is legacy","If your portversion release genuinely changed the format, patch the regex at lib/puppet/provider/package/ports.rb:60 and open an upstream Puppet issue"],"exampleFix":"// before\npackage { 'mail/postfix':\n  ensure   => latest,\n  provider => ports,\n}\n// after - pkgng is the maintained FreeBSD provider\npackage { 'mail/postfix':\n  ensure   => latest,\n  provider => pkgng,\n}","handlingStrategy":"try-catch","validationCode":"# Ruby: verify portversion emits parseable output before relying on latest\ndef parseable_portversion_info?(origin)\n  out = Puppet::Util::Execution.execute(['/usr/local/sbin/portversion', '-v', origin], failonfail: false).to_s\n  line = out.split(\"\\n\").last.to_s\n  m = line.match(/^(\\S+)\\s+(\\S)\\s+(.+)$/)\n  !m.nil? && (m[2] =~ /[=>]/ || m[3] =~ /\\((\\w+) has (.+)\\)/)\nend","typeGuard":null,"tryCatchPattern":"begin\n  latest_version = provider.latest\nrescue Puppet::Error => e\n  Puppet.debug(\"portversion output unparseable for #{resource[:name]}: #{e.message}\")\n  latest_version = provider.query&.fetch(:ensure, nil) # fall back to installed version\nend","preventionTips":["Keep the ports tree and pkgdb synchronized (portsnap + pkgdb -aFu) on hosts using ensure => latest with the ports provider","Prefer the pkgng provider on FreeBSD 10+; the portupgrade tooling is legacy and its output format drifts","Pin the portupgrade suite version in images so portversion output stays predictable"],"tags":["freebsd","ports","portversion","regex-parse","package-provider"],"backgroundTag":"command-output-parse-failure","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}