{"record":{"id":"9983cbb7baf013e6","repo":"puppetlabs/puppet","slug":"could-not-uninstall-module-name-installed-mo","errorCode":null,"errorMessage":"Could not uninstall '%{module_name}'; installed modules still depend upon it","messagePattern":"Could not uninstall '%(.+?)'; installed modules still depend upon it","errorType":"exception","errorClass":"Puppet::ModuleTool::Errors::ModuleIsRequiredError","httpStatus":null,"severity":"error","filePath":"lib/puppet/module_tool/applications/uninstaller.rb","lineNumber":112,"sourceCode":"          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)\n\n          changes = begin\n            Puppet::ModuleTool::Applications::Checksummer.run(mod.path)\n          rescue ArgumentError\n            []\n          end\n\n          if mod.has_metadata? && !changes.empty?\n            raise LocalChangesError,\n                  :action => :uninstall,\n                  :module_name => (mod.forge_name || mod.name).tr('/', '-'),\n                  :requested_version => @options[:version],\n                  :installed_version => mod.version\n          end\n        end\n\n        if !@options[:force] && !mod.required_by.empty?\n          raise ModuleIsRequiredError,\n                :module_name => (mod.forge_name || mod.name).tr('/', '-'),\n                :required_by => mod.required_by,\n                :requested_version => @options[:version],\n                :installed_version => mod.version\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":94,"sourceCodeEnd":122,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/module_tool/applications/uninstaller.rb#L94-L122","documentation":"Raised by Puppet::ModuleTool::Applications::Uninstaller as Puppet::ModuleTool::Errors::ModuleIsRequiredError (subclass of UninstallError) when other installed modules declare the target as a dependency in their metadata.json. The uninstaller checks mod.required_by and, unless --force is given, refuses to remove a module that would break its dependents. The error's multiline output lists exactly which modules require it.","triggerScenarios":"Running `puppet module uninstall <name>` without --force when at least one other module in the environment's module path lists <name> in the dependencies of its metadata.json, e.g. uninstalling puppetlabs-stdlib while puppetlabs-apache requires it.","commonSituations":"Trying to remove widely shared modules like stdlib, concat, or translate; stale metadata.json of hand-copied modules still referencing the module; cleaning up after a refactoring that removed the last real consumer but left the dependency declaration behind.","solutions":["Uninstall the dependent modules first (the error message lists them via required_by), then uninstall this one","If the dependents' declarations are stale, edit their metadata.json to drop the dependency, then uninstall","Override deliberately with `puppet module uninstall <name> --force` (note: --force also skips the local-changes check)","Map the tree first with `puppet module list --tree` to see which modules pull it in"],"exampleFix":"# before\n$ puppet module uninstall puppetlabs-stdlib\n# Error: Could not uninstall 'puppetlabs-stdlib'; installed modules still depend upon it\n\n# after\n$ puppet module uninstall puppetlabs-apache\n$ puppet module uninstall puppetlabs-stdlib","handlingStrategy":"validation","validationCode":"mod = env.modules.find { |m| (m.forge_name || m.name).tr('/', '-') == name }\nunless mod.nil? || mod.required_by.empty?\n  dependents = mod.required_by.map { |r| r['name'] }.join(', ')\n  abort \"#{name} is required by: #{dependents} — uninstall those first or pass --force\"\nend","typeGuard":null,"tryCatchPattern":"result = Puppet::ModuleTool::Applications::Uninstaller.run(name, options)\nif (m = result[:error] && result[:error][:oneline] =~ /still depend upon/)\n  dependents = mod.required_by.map { |r| r['name'] }\n  dependents.each { |d| Puppet::ModuleTool::Applications::Uninstaller.run(d, options) }\n  Puppet::ModuleTool::Applications::Uninstaller.run(name, options)\nend","preventionTips":["Inspect `puppet module list --tree` before removing shared dependencies","When refactoring, clean dependency declarations out of dependents' metadata.json, not just the code","In scripts, uninstall leaf modules first (topological order) rather than relying on --force"],"tags":["puppet","module-tool","uninstall","dependencies","required-by"],"backgroundTag":"dependency-in-use","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}