voormedia/rails-erd · error
Saving diagram failed! Output directory '#{dir}' does not ex
Error message
Saving diagram failed!
Output directory '#{dir}' does not exist. What it means
Error "Saving diagram failed! Output directory '#{dir}' does not exist." thrown in voormedia/rails-erd.
Source
Thrown at lib/rails_erd/diagram/tbls.rb:42
next unless entity.model
table_name = entity.model.table_name
next if tables_by_name.key?(table_name)
tables_by_name[table_name] = build_table(entity)
end
each_relationship do |relationship|
next if relationship.indirect?
next unless relationship.source && relationship.destination
next if relationship.source.generalized? || relationship.destination.generalized?
add_foreign_keys(relationship)
end
save do
dir = File.dirname(filename)
raise "Saving diagram failed!\nOutput directory '#{dir}' does not exist." unless File.directory?(dir)
File.write(filename, JSON.pretty_generate(schema_payload))
filename
end
def filename
"#{options.filename}.json"
end
private
def schema_payload
{
name: domain.name || "rails-erd",
tables: tables_by_name.values,
}
end
View on GitHub (pinned to dae6e52018)
Solutions
- Create the output directory before running the task: `mkdir -p <dir>` (the directory named in the error message).
- Pass a filename whose parent directory already exists, e.g. `bundle exec rake erd filename=erd` for the project root, or create the target directory first.
Example fix
mkdir -p doc && bundle exec rake erd filename=doc/erd
When it happens
Trigger: Raised by the tbls generator's save block when the directory portion of the configured output filename (File.dirname(filename)) is not an existing directory, e.g. running `rake erd generator=tbls filename=docs/erd` while the docs/ directory has not been created.
Common situations: See trigger scenarios.
AI-assisted analysis of voormedia/rails-erd@dae6e52018 (2026-08-23).
Data as JSON: /api/errors/596c93f0e3b9391a.
Report an issue: GitHub.