{"record":{"id":"e9cdbf8e996fbf39","repo":"puppetlabs/puppet","slug":"module-name-version-requested-module","errorCode":null,"errorMessage":"'%{module_name}' (%{version}) requested; '%{module_name}' (%{installed_version}) already installed","messagePattern":"'%(.+?)' \\(%(.+?)\\) requested; '%(.+?)' \\(%(.+?)\\) already installed","errorType":"exception","errorClass":"Puppet::ModuleTool::Errors::AlreadyInstalledError","httpStatus":null,"severity":"error","filePath":"lib/puppet/module_tool/applications/installer.rb","lineNumber":80,"sourceCode":"        begin\n          if !@local_tarball && name !~ /-/\n            raise InvalidModuleNameError.new(module_name: @name, suggestion: \"puppetlabs-#{@name}\", action: :install)\n          end\n\n          installed_module = installed_modules[name]\n          if installed_module\n            unless forced?\n              if Puppet::Module.parse_range(version).include? installed_module.version\n                results[:result] = :noop\n                results[:version] = installed_module.version\n                return results\n              else\n                changes = begin\n                  Checksummer.run(installed_modules[name].mod.path)\n                rescue\n                  []\n                end\n                raise AlreadyInstalledError,\n                      :module_name => name,\n                      :installed_version => installed_modules[name].version,\n                      :requested_version => options[:version] || :latest,\n                      :local_changes => changes\n              end\n            end\n          end\n\n          @install_dir.prepare(name, options[:version] || 'latest')\n          results[:install_dir] = @install_dir.target\n\n          unless @local_tarball && @ignore_dependencies\n            Puppet.notice _(\"Downloading from %{host} ...\") % {\n              host: mask_credentials(module_repository.host)\n            }\n          end\n\n          if @ignore_dependencies","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/module_tool/applications/installer.rb#L62-L98","documentation":"Installer raises Puppet::ModuleTool::AlreadyInstalledError when the module is already installed, --force was not given, and the installed version does not satisfy the requested version range (if it did satisfy, the installer would return :noop instead). The error carries installed_version, requested_version, and local_changes (from Checksummer) so the CLI can advise using `puppet module upgrade` or --force. `puppet module install` never changes an installed version; it only installs what is missing.","triggerScenarios":"Running `puppet module install puppetlabs-stdlib` (or with a --version range) when site-modules/stdlib exists at a version outside that range — e.g. installed 4.25.0 and requesting '>= 5.0.0 < 6.0.0', or requesting a specific older version than what is present. Raised at installer.rb:80 from the installed_module branch.","commonSituations":"Pinning versions in Puppetfile after a module was already installed at another version; re-running install after manually editing metadata.json's version; trying to 'reinstall' or downgrade via install instead of upgrade; local modifications present making the hint mention local changes.","solutions":["Use `puppet module upgrade <author>-<name>` (optionally with --version) when you want a newer version than installed.","Uninstall first (`puppet module uninstall`) then install the exact version desired.","Add --force to install to overwrite/downgrade regardless of the installed version (mind local changes).","Omit or widen --version so the requested range includes the installed version, yielding a no-op instead of an error."],"exampleFix":"# before\npuppet module install puppetlabs-stdlib --version 5.0.0   # 4.25.0 installed\n\n# after\npuppet module uninstall puppetlabs-stdlib && puppet module install puppetlabs-stdlib --version 5.0.0\n# or: puppet module upgrade puppetlabs-stdlib --version 5.0.0","handlingStrategy":"try-catch","validationCode":"installed = environment.modules.find { |m| m.forge_name == slug }\nif installed\n  requested = Puppet::Module.parse_range(version || '>= 0')\n  exit 0 if requested.include?(installed.version) # no-op like the installer\nend","typeGuard":null,"tryCatchPattern":"begin\n  Puppet::ModuleTool::Applications::Installer.new(name, options).run\nrescue Puppet::ModuleTool::AlreadyInstalledError => e\n  # e.multiline_options has installed_version / local_changes\n  run_upgrade_or_force(name)\nend","preventionTips":["Use `puppet module upgrade` (or r10k/Puppetfile) as the standard way to change versions; reserve install for absent modules.","Make install steps idempotent: check `puppet module list` first and skip when the desired version range is satisfied.","In automation, catch AlreadyInstalledError and treat it as success when the installed version is acceptable."],"tags":["puppet","module-tool","install","version-conflict"],"backgroundTag":"package-already-installed","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}