puppetlabs/puppet · error · ArgumentError
The output directory '%{outputdir}' exists and is not a dire
Error message
The output directory '%{outputdir}' exists and is not a directory What it means
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.
Source
Thrown at lib/puppet/face/generate.rb:58
end
option '--force' do
summary _('Forces the generation of output files (skips up-to-date checks).')
default_to { false }
end
when_invoked do |options|
generator = Puppet::Generate::Type
inputs = generator.find_inputs(options[:format].to_sym)
environment = Puppet.lookup(:current_environment)
# get the common output directory (in <envroot>/.resource_types) - create it if it does not exists
# error if it exists and is not a directory
#
path_to_env = environment.configuration.path_to_env
outputdir = File.join(path_to_env, '.resource_types')
if Puppet::FileSystem.exist?(outputdir) && !Puppet::FileSystem.directory?(outputdir)
raise ArgumentError, _("The output directory '%{outputdir}' exists and is not a directory") % { outputdir: outputdir }
end
Puppet::FileSystem.mkpath(outputdir)
generator.generate(inputs, outputdir, options[:force])
exit(1) if generator.bad_input?
nil
end
end
end
View on GitHub (pinned to e227c27540)
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`
Example fix
# before ls -la production/.resource_types # regular file → error # after rm production/.resource_types puppet generate types --environment production
Defensive patterns
Strategy: validation
Validate before calling
outdir = File.join(env.configuration.path_to_env, '.resource_types')
if File.exist?(outdir) && !File.directory?(outdir)
abort "#{outdir} exists and is not a directory"
end Type guard
def resource_types_dir_writable?(env) path = File.join(env.configuration.path_to_env, '.resource_types') !File.exist?(path) || File.directory?(path) end
Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- '%{format}' is not a supported format for type generation.
- Can not create #{@resource.title}; #{dirname} is not a direc
- Could not destroy %{json} %{request}: %{detail}
- Could not read JSON data for %{name} %{key}: %{detail}
- Could not destroy %{name} %{request}: %{detail}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/366237d2eed6db7f.
Report an issue: GitHub.