{"record":{"id":"b0cc7346adf17bef","repo":"puppetlabs/puppet","slug":"could-not-match-package-info-pkgstuff","errorCode":null,"errorMessage":"Could not match package info '%{pkgstuff}'","messagePattern":"Could not match package info '%(.+?)'","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/ports.rb","lineNumber":47,"sourceCode":"\n    begin\n      output = portversion(*cmd)\n    rescue Puppet::ExecutionFailure => e\n      raise Puppet::Error.new(output, e)\n    end\n    line = output.split(\"\\n\").pop\n\n    unless line =~ /^(\\S+)\\s+(\\S)\\s+(.+)$/\n      # There's no \"latest\" version, so just return a placeholder\n      return :latest\n    end\n\n    pkgstuff = Regexp.last_match(1)\n    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)","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/ports.rb#L29-L65","documentation":"Raised in `latest` (lib/puppet/provider/package/ports.rb:47) of the FreeBSD ports provider. It takes the last line of `portversion -v <name>` output and requires the first column (`pkgstuff`, e.g. `www/nginx-1.2.3`) to end in a dash-version suffix; when it does not, the version cannot be extracted and Puppet::Error 'Could not match package info' is raised.","triggerScenarios":"portversion printing a first column with no `-version` part: a moved/removed port whose entry lost its version, an origin-only line like `www/nginx`, or column formatting that shifted under the regex.","commonSituations":"Ports tree mid-move (MOVED entries) or out of sync with installed packages; portupgrade/portversion tools older than the current ports layout; leftover stale package database entries.","solutions":["Run `portversion -v <name>` and inspect the first column the error quotes.","Update the ports tree (`portsnap fetch update`) and reinstall ports-mgmt/portupgrade to current versions.","If the port moved, update the resource to the new origin.","Clean stale package registrations (`pkgdb -F` in the portupgrade world) so portversion output is well-formed."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# Confirm portversion emits a parseable first column before the run\nline=$(portversion -v \"${name}\" 2>/dev/null | tail -1)\necho \"$line\" | awk '{ print $1 }' | grep -Eq '\\S+-[^-\\s]+$' || echo \"unparseable portversion output - update ports/portupgrade\"","typeGuard":null,"tryCatchPattern":"begin\n  latest = provider.latest\nrescue Puppet::Error => e\n  raise unless e.message =~ /Could not match package info/\n  latest = :latest # degrade gracefully: treat as unknown/uptodate\nend","preventionTips":["Keep ports-mgmt/portupgrade and the ports tree in sync on managed FreeBSD nodes.","Clean stale package registrations (pkgdb -F) after ports moves.","Smoke-test `portversion -v <name>` output shape in CI for your port set."],"tags":["freebsd","ports","portversion","parse-error"],"backgroundTag":"command-output-parse-failure","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}