{"record":{"id":"366237d2eed6db7f","repo":"puppetlabs/puppet","slug":"the-output-directory-outputdir-exists-and-is","errorCode":null,"errorMessage":"The output directory '%{outputdir}' exists and is not a directory","messagePattern":"The output directory '%(.+?)' exists and is not a directory","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/face/generate.rb","lineNumber":58,"sourceCode":"    end\n\n    option '--force' do\n      summary _('Forces the generation of output files (skips up-to-date checks).')\n      default_to { false }\n    end\n\n    when_invoked do |options|\n      generator = Puppet::Generate::Type\n      inputs = generator.find_inputs(options[:format].to_sym)\n      environment = Puppet.lookup(:current_environment)\n\n      # get the common output directory (in <envroot>/.resource_types) - create it if it does not exists\n      # error if it exists and is not a directory\n      #\n      path_to_env = environment.configuration.path_to_env\n      outputdir = File.join(path_to_env, '.resource_types')\n      if Puppet::FileSystem.exist?(outputdir) && !Puppet::FileSystem.directory?(outputdir)\n        raise ArgumentError, _(\"The output directory '%{outputdir}' exists and is not a directory\") % { outputdir: outputdir }\n      end\n\n      Puppet::FileSystem.mkpath(outputdir)\n\n      generator.generate(inputs, outputdir, options[:force])\n\n      exit(1) if generator.bad_input?\n      nil\n    end\n  end\nend\n","sourceCodeStart":40,"sourceCodeEnd":70,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/face/generate.rb#L40-L70","documentation":"Raised by `puppet generate types` when the per-environment output directory `<envroot>/.resource_types` exists but is not a directory (typically a regular file). The face happily creates the directory when it is absent (`mkpath`), but refuses to clobber an existing non-directory path, so the run stops before generating anything.","triggerScenarios":"`puppet generate types --environment <env>` where `<envroot>/.resource_types` was previously created as a file — e.g. a `touch .resource_types` marker, a botched deploy script, or an interrupted earlier run that left a file behind.","commonSituations":"Deploy tooling that creates marker files; environment code dirs restored from archives with wrong file types; puppet.conf environmentpath pointing somewhere unexpected so the same name collides.","solutions":["Inspect the path: `ls -la <envroot>/.resource_types`","If it is a stray file, remove or rename it (`mv .resource_types .resource_types.bak`)","Re-run `puppet generate types` — it now creates a proper directory and generates into it","Fix the pipeline step that created a file instead of `mkdir -p`"],"exampleFix":"# before\nls -la production/.resource_types    # regular file → error\n# after\nrm production/.resource_types\npuppet generate types --environment production","handlingStrategy":"validation","validationCode":"outdir = File.join(env.configuration.path_to_env, '.resource_types')\nif File.exist?(outdir) && !File.directory?(outdir)\n  abort \"#{outdir} exists and is not a directory\"\nend","typeGuard":"def resource_types_dir_writable?(env)\n  path = File.join(env.configuration.path_to_env, '.resource_types')\n  !File.exist?(path) || File.directory?(path)\nend","tryCatchPattern":null,"preventionTips":["Never create .resource_types as a marker file; use mkdir -p in pipelines","Check environmentpath in puppet.conf when this fires unexpectedly","Clean stale .resource_types artifacts after interrupted generation runs"],"tags":["puppet-generate","types","filesystem","path-conflict"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}