puppetlabs/puppet · error · Puppet::ModuleTool::Errors::NoVersionMatchesError

Could not uninstall '%{module_name}'; no installed version m

Error message

Could not uninstall '%{module_name}'; no installed version matches

What it means

Uninstaller raises Puppet::ModuleTool::NoVersionMatchesError when @installed is empty but @unfiltered is not: directories with the matching module name exist, yet none of their versions falls inside the --version range given. The error lists the unfiltered installed modules and the version_range so the user can see which versions are present versus requested.

Source

Thrown at lib/puppet/module_tool/applications/uninstaller.rb:82

            @installed << mod
          elsif mod_name =~ /#{@name}/
            @suggestions << mod_name
          end
        end

        if @installed.length > 1
          raise MultipleInstalledError,
                :action => :uninstall,
                :module_name => @name,
                :installed_modules => @installed.sort_by { |mod| @environment.modulepath.index(mod.modulepath) }
        elsif @installed.empty?
          if @unfiltered.empty?
            raise NotInstalledError,
                  :action => :uninstall,
                  :suggestions => @suggestions,
                  :module_name => @name
          else
            raise NoVersionMatchesError,
                  :installed_modules => @unfiltered.sort_by { |mod| @environment.modulepath.index(mod[:path]) },
                  :version_range => @options[:version],
                  :module_name => @name
          end
        end
      end

      def validate_module
        mod = @installed.first

        unless @ignore_changes
          raise _("Either the `--ignore_changes` or `--force` argument must be specified to uninstall modules when running in FIPS mode.") if Puppet.runtime[:facter].value(:fips_enabled)

          changes = begin
            Puppet::ModuleTool::Applications::Checksummer.run(mod.path)
          rescue ArgumentError
            []
          end

View on GitHub (pinned to e227c27540)

Solutions

  1. Check the actual installed version with `puppet module list` and adjust the --version range to include it.
  2. Omit --version entirely to uninstall regardless of version.
  3. If the installed version in metadata.json is wrong, fix it or uninstall without a version filter.

Example fix

# before
puppet module uninstall stdlib --version '>= 5.0.0'   # installed: 4.25.1

# after
puppet module uninstall stdlib --version '4.25.1'
# or simply: puppet module uninstall stdlib
Defensive patterns

Strategy: validation

Validate before calling

mod = environment.modules.find { |m| m.name == @name }
if mod && options[:version]
  range = Puppet::Module.parse_range(options[:version])
  abort "installed #{mod.version} outside #{options[:version]}" unless range.include?(SemanticPuppet::Version.parse(mod.version))
end

Try / catch

begin
  uninstaller.run
rescue Puppet::ModuleTool::NoVersionMatchesError => e
  opts = e.multiline_options # :installed_modules, :version_range
  retry_without_version_filter(opts)
end

Prevention

When it happens

Trigger: Running `puppet module uninstall stdlib --version '>= 5.0.0'` when the installed stdlib is 4.25.1 — the name matched (module went into @unfiltered) but the version filter excluded it from @installed, leaving @installed empty while @unfiltered has entries.

Common situations: Version ranges written against an outdated expectation of what is deployed; metadata.json of the installed module edited so its version no longer matches reality; scripts parameterized with module versions that drifted across environments.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/e5c0a0c15444ba6a. Report an issue: GitHub.