{"record":{"id":"61ea76f9f5b97bf4","repo":"voormedia/rails-erd","slug":"saving-diagram-failed-graphviz-produced-errors-v","errorCode":null,"errorMessage":"Saving diagram failed!\nGraphviz produced errors. Verify it has support for filetype=#{options.filetype}, or use filetype=dot.\nOriginal error: #{e.message.split(\"\\n\").last}","messagePattern":"Saving diagram failed!\nGraphviz produced errors\\. Verify it has support for filetype=#(.+?), or use filetype=dot\\.\nOriginal error: #(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/rails_erd/diagram/graphviz.rb","lineNumber":223,"sourceCode":"        # Title of the graph itself.\n        graph[:label] = \"#{title}\\\\n\\\\n\" if title\n\n        # Style of splines\n        graph[:splines] = options.splines unless options.splines.nil?\n\n        # Setup notation options.\n        extend self.class.const_get(options.notation.to_s.capitalize.to_sym)\n      end\n\n      save do\n        raise \"Saving diagram failed!\\nOutput directory '#{File.dirname(filename)}' does not exist.\" unless File.directory?(File.dirname(filename))\n\n        begin\n          # GraphViz doesn't like spaces in the filename\n          graph.output(filetype => filename.gsub(/\\s/,\"_\"))\n          filename\n        rescue RuntimeError => e\n          raise \"Saving diagram failed!\\nGraphviz produced errors. Verify it \" +\n                  \"has support for filetype=#{options.filetype}, or use \" +\n                  \"filetype=dot.\\nOriginal error: #{e.message.split(\"\\n\").last}\"\n        rescue StandardError => e\n          raise \"Saving diagram failed!\\nVerify that Graphviz is installed \" +\n                  \"and in your path, or use filetype=dot.\"\n        end\n      end\n\n      each_entity do |entity, attributes|\n        if options[:cluster] && entity.namespace\n          cluster_name = \"cluster_#{entity.namespace}\"\n          cluster_options = CLUSTER_ATTRIBUTES.merge(label: entity.namespace)\n          cluster = graph.get_graph(cluster_name) ||\n                    graph.add_graph(cluster_name, cluster_options)\n\n          draw_cluster_node cluster, entity.name, entity_options(entity, attributes)\n        else\n          draw_node entity.name, entity_options(entity, attributes)","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/voormedia/rails-erd/blob/dae6e52018c94ff6d3e3bb0fdbc2cb0c680ec165/lib/rails_erd/diagram/graphviz.rb#L205-L241","documentation":"Once the directory check passes, save calls graph.output(filetype => filename) (graphviz.rb:218-221), which shells out to the Graphviz 'dot' binary. ruby-graphviz raises RuntimeError when dot exits non-zero; rails-erd rescues it and re-raises with the requested filetype plus the last line of dot's stderr (graphviz.rb:222-225). So dot ran but rejected the request -- most often the installed Graphviz build lacks the renderer for options.filetype (default :pdf), or dot choked on something in the generated graph.","triggerScenarios":"rake erd filetype=png / filetype=svg / filetype=pdf against a Graphviz build compiled without that renderer (typical on Alpine or debian-slim images lacking cairo/pango); a typo'd filetype such as filetype=pgn; any condition that makes 'dot -T<fmt>' exit non-zero (missing font, bad attribute).","commonSituations":"Diagram renders on the dev machine (full Homebrew/apt graphviz) but fails in Alpine or slim CI images; distro package changes dropping an optional format; switching filetype from pdf to png on a server; ERD_FILETYPE set in an ignored environment file.","solutions":["Reproduce the real error: generate with filetype=dot, then run dot -T<fmt> ERD.dot manually to read dot's full stderr","List the formats your build supports: dot -T?","If the format is unsupported, install a full Graphviz build (apt-get install -y graphviz on a full base image, or add the cairo/pango deps on Alpine) or fall back to a supported format such as pdf or dot"],"exampleFix":"# before (Alpine CI)\nrake erd filetype=png\n# => RuntimeError: ... Verify it has support for filetype=png ...\n\n# after (Dockerfile)\nRUN apk add --no-cache graphviz ttf-dejavu\n# or fall back to a format the build supports:\nrake erd filetype=dot","handlingStrategy":"try-catch","validationCode":"fmt = :png\nok = system('dot', '-T' + fmt.to_s, '-o', '/dev/null', in: '/dev/null', err: File::NULL)\nRailsERD::Diagram::Graphviz.create(filetype: ok ? fmt : :dot)","typeGuard":null,"tryCatchPattern":"begin\n  RailsERD::Diagram::Graphviz.create(filetype: :png)\nrescue RuntimeError => e\n  raise unless e.message.include?('Graphviz produced errors')\n  warn 'falling back to filetype=dot'\n  RailsERD::Diagram::Graphviz.create(filetype: :dot)\nend","preventionTips":["Assert that dot -T<filetype> exits 0 in CI before the erd step","Treat filetype=dot as the portable baseline and render to png/pdf only where a full Graphviz is guaranteed","Pin a full-featured graphviz package in Dockerfiles (add cairo/pango deps on Alpine)"],"tags":["ruby","rails-erd","graphviz","dot","filetype","renderer-support","docker"],"backgroundTag":"graphviz-unsupported-output-format","analyzedSha":"dae6e52018c94ff6d3e3bb0fdbc2cb0c680ec165","analyzedAt":"2026-08-23T02:52:18.679Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}