jordansissel/fpm · error · FPM::InvalidPackageConfiguration

Could not find package metadata. Checked for META.json, META

Error message

Could not find package metadata. Checked for META.json, META.yml, and MetaCPAN API data

What it means

The cpan input builds metadata from two sources: a MetaCPAN API query for the module, and local META.json / META.yml / MYMETA.yml if present in the module directory. If both yield nothing (the merged hash is empty), FPM::InvalidPackageConfiguration is raised — fpm has no name or version to build from.

Source

Thrown at lib/fpm/package/cpan.rb:92

      local_metadata = JSON.parse(File.read(File.join(moduledir, ("META.json"))))
    elsif File.exist?(File.join(moduledir, ("META.yml")))
      require "yaml"
      local_metadata = YAML.load_file(File.join(moduledir, ("META.yml")))
    elsif File.exist?(File.join(moduledir, "MYMETA.json"))
      local_metadata = JSON.parse(File.read(File.join(moduledir, ("MYMETA.json"))))
    elsif File.exist?(File.join(moduledir, ("MYMETA.yml")))
      require "yaml"
      local_metadata = YAML.load_file(File.join(moduledir, ("MYMETA.yml")))
    end

    # Merge the MetaCPAN query result and the metadata pulled from the local
    # META file(s).  The local data overwrites the query data for all keys the
    # two hashes have in common.  Merge with an empty hash if there was no
    # local META file.
    metadata = result.merge(local_metadata || {})

    if metadata.empty?
      raise FPM::InvalidPackageConfiguration,
        "Could not find package metadata. Checked for META.json, META.yml, and MetaCPAN API data"
    end

    self.version = metadata["version"]
    self.description = metadata["abstract"]

    self.license = case metadata["license"]
      when Array; metadata["license"].first
      when nil; "unknown"
      else; metadata["license"]
    end

    unless metadata["release"].nil?
      dist_name, _, dist_version = metadata["release"].rpartition('-')
      logger.info("Setting package name from 'distribution'",
                  :distribution => dist_name)
      self.name = fix_name(dist_name)
      self.provides = search_provided_modules(dist_name, dist_version)

View on GitHub (pinned to b6d77ba72a)

Solutions

  1. Run 'perl Makefile.PL' (or Build.PL) in the module dir to generate MYMETA, then pass the directory path to fpm
  2. Verify MetaCPAN reachability: curl https://fastapi.metacpan.org/v1/module/Your::Module
  3. For private modules, fall back to -s dir with explicit --name/--version, or vendor a META.yml into the dist
  4. Double-check the module name spelling and that it exists on CPAN

Example fix

# before (offline, bare source dir)
fpm -s cpan -t deb My::Internal::Module

# after: generate local metadata, package from the directory
(cd My-Internal-Module && perl Makefile.PL)
fpm -s cpan -t deb ./My-Internal-Module
Defensive patterns

Strategy: try-catch

Validate before calling

meta_sources = %w[META.json META.yml MYMETA.yml]
has_local_meta = meta_sources.any? { |m| File.exist?(File.join(module_dir, m)) }
net_ok = system('curl', '-fsS', 'https://fastapi.metacpan.org/v1/module/Your::Module', out: File::NULL, err: File::NULL)
abort 'no CPAN metadata source available (offline and no META files)' unless has_local_meta || net_ok

Try / catch

begin
  pkg = FPM::Package::Cpan.new
  pkg.input('Some::Module')
rescue FPM::InvalidPackageConfiguration => e
  warn "no CPAN metadata found (#{e.message}); check network or add META.yml/MYMETA.yml"
  pkg.cleanup
end

Prevention

When it happens

Trigger: Running 'fpm -s cpan -t deb Some::Module' offline or behind a blocking proxy (MetaCPAN query returns nothing) while the module directory has no META files; a typo'd module name not found on MetaCPAN; private/internal Perl distributions never published to CPAN.

Common situations: Air-gapped or firewalled build agents; corporate proxies blocking fastapi.metacpan.org; packaging internal modules; pointing -s cpan at a bare source dir where perl Makefile.PL was never run (no MYMETA generated).

Related errors


AI-assisted analysis of jordansissel/fpm@b6d77ba72a (2026-08-21). Data as JSON: /api/errors/211d21e256eb365b. Report an issue: GitHub.