{"record":{"id":"45eeb7a8cab7512f","repo":"puppetlabs/puppet","slug":"could-not-action-module-name-module-appea","errorCode":null,"errorMessage":"Could not %{action} '%{module_name}'; module appears in multiple places in the module path","messagePattern":"Could not %(.+?) '%(.+?)'; module appears in multiple places in the module path","errorType":"exception","errorClass":"Puppet::ModuleTool::Errors::MultipleInstalledError","httpStatus":null,"severity":"error","filePath":"lib/puppet/module_tool/applications/uninstaller.rb","lineNumber":71,"sourceCode":"        @environment.modules_by_path.values.flatten.each do |mod|\n          mod_name = (mod.forge_name || mod.name).tr('/', '-')\n          if mod_name == @name\n            @unfiltered << {\n              :name => mod_name,\n              :version => mod.version,\n              :path => mod.modulepath,\n            }\n            if @options[:version] && mod.version\n              next unless Puppet::Module.parse_range(@options[:version]).include?(SemanticPuppet::Version.parse(mod.version))\n            end\n            @installed << mod\n          elsif mod_name =~ /#{@name}/\n            @suggestions << mod_name\n          end\n        end\n\n        if @installed.length > 1\n          raise MultipleInstalledError,\n                :action => :uninstall,\n                :module_name => @name,\n                :installed_modules => @installed.sort_by { |mod| @environment.modulepath.index(mod.modulepath) }\n        elsif @installed.empty?\n          if @unfiltered.empty?\n            raise NotInstalledError,\n                  :action => :uninstall,\n                  :suggestions => @suggestions,\n                  :module_name => @name\n          else\n            raise NoVersionMatchesError,\n                  :installed_modules => @unfiltered.sort_by { |mod| @environment.modulepath.index(mod[:path]) },\n                  :version_range => @options[:version],\n                  :module_name => @name\n          end\n        end\n      end\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/module_tool/applications/uninstaller.rb#L53-L89","documentation":"Uninstaller raises Puppet::ModuleTool::MultipleInstalledError when more than one module matching the requested name is found across the modulepath entries. Uninstalling would be ambiguous (which copy?), so the error lists every installed_modules entry sorted by modulepath order. Note the version filter first narrows @installed when --version is passed.","triggerScenarios":"Running `puppet module uninstall stdlib` when both /etc/puppetlabs/code/environments/prod/modules/stdlib and /etc/puppetlabs/code/modules/stdlib exist; the same module copied into an environment and the global modules directory; basemodulepath copies. @installed.length > 1 triggers it.","commonSituations":"Environments inheriting modules duplicated in the global modulepath; manually copied modules during debugging; distro packages installing modules system-wide that also exist per-environment.","solutions":["Disambiguate with the --version flag if the copies differ in version (the version filter runs before the multiplicity check).","Remove the duplicate copy from one modulepath directory (keep the one in the intended scope), then re-run uninstall.","Use the full environment/modulepath layout to confirm where each copy lives: `puppet module list --modulepath <dir>` for each entry."],"exampleFix":"# before\npuppet module uninstall stdlib   # two copies: env modules + global modules\n\n# after\nrm -rf /etc/puppetlabs/code/modules/stdlib   # remove the stray copy\npuppet module uninstall stdlib","handlingStrategy":"validation","validationCode":"matches = Puppet.settings[:modulepath].split(File::PATH_SEPARATOR).flat_map do |dir|\n  Dir.glob(File.join(dir, @name)).select { |d| File.directory?(d) }\nend\nabort 'module appears in multiple modulepath entries' if matches.size > 1","typeGuard":null,"tryCatchPattern":"begin\n  uninstaller.run\nrescue Puppet::ModuleTool::MultipleInstalledError => e\n  mods = e.multiline_options[:installed_modules]\n  choose_and_narrow(mods) # e.g. add --version to disambiguate\nend","preventionTips":["Keep each module in exactly one modulepath location (per-environment or global, never both).","Disambiguate uninstall commands with --version when copies legitimately differ.","Audit for duplicates with `puppet module list` across each modulepath entry during environment reviews."],"tags":["puppet","module-tool","uninstall","modulepath","duplicate-module"],"backgroundTag":"duplicate-package-install","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}