保存图表失败!验证 Graphviz 是不是已安装并在您的路径中,或使用 filetype=dot

Posted

技术标签:

【中文标题】保存图表失败!验证 Graphviz 是不是已安装并在您的路径中,或使用 filetype=dot【英文标题】:Saving diagram failed! Verify that Graphviz is installed and in your path, or use filetype=dot保存图表失败!验证 Graphviz 是否已安装并在您的路径中,或使用 filetype=dot 【发布时间】:2016-05-04 11:48:12 【问题描述】:

当我运行rake db:migrate 时出现此错误

rake aborted!
Saving diagram failed!
Verify that Graphviz is installed and in your path, or use filetype=dot.

完整日志:

rake db:migrate
Loading application environment...
Loading code in search of Active Record models...
Generating Entity-Relationship Diagram for 20 models...
rake aborted!
Saving diagram failed!
Verify that Graphviz is installed and in your path, or use filetype=dot.
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:207:in `rescue in block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:198:in `block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `instance_eval'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `save'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:120:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:74:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/tasks.rake:41:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:18:in `update_model'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:3:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
StandardError: GraphViz not installed or dot not in PATH. Install GraphViz or use the 'path' option
/home/bcc/.rvm/gems/ruby-2.2.3/gems/ruby-graphviz-1.2.2/lib/graphviz.rb:544:in `output'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:200:in `block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `instance_eval'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `save'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:120:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:74:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/tasks.rake:41:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:18:in `update_model'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:3:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => erd => erd:generate
(See full trace by running task with --trace)
bcc@bcc /media/bcc/Other/work/incomingerasmus $ git branch
  master
* rails4
bcc@bcc /media/bcc/Other/work/incomingerasmus $ rake db:migrate
Loading application environment...
Loading code in search of Active Record models...
Generating Entity-Relationship Diagram for 20 models...
rake aborted!
Saving diagram failed!
Verify that Graphviz is installed and in your path, or use filetype=dot.
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:207:in `rescue in block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:198:in `block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `instance_eval'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `save'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:120:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:74:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/tasks.rake:41:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:18:in `update_model'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:3:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
StandardError: GraphViz not installed or dot not in PATH. Install GraphViz or use the 'path' option
/home/bcc/.rvm/gems/ruby-2.2.3/gems/ruby-graphviz-1.2.2/lib/graphviz.rb:544:in `output'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:200:in `block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `instance_eval'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `save'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:120:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:74:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/tasks.rake:41:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:18:in `update_model'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:3:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => erd => erd:generate
(See full trace by running task with --trace)

如果我使用 --trace 运行命令,我会得到这个

rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment 
** Invoke db:load_config 
** Execute db:schema:dump
** Invoke erd (first_time)
** Invoke erd:generate (first_time)
** Invoke erd:options (first_time)
** Execute erd:options
** Invoke erd:load_models (first_time)
** Execute erd:load_models
Loading application environment...
** Invoke environment 
Loading code in search of Active Record models...
** Execute erd:generate
Generating Entity-Relationship Diagram for 20 models...
rake aborted!
Saving diagram failed!
Verify that Graphviz is installed and in your path, or use filetype=dot.
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:207:in `rescue in block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:198:in `block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `instance_eval'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `save'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:120:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:74:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/tasks.rake:41:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/bcc/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:199:in `each'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:199:in `invoke_prerequisites'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/home/bcc/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:18:in `update_model'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:3:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/bcc/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/rake:23:in `load'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/rake:23:in `<main>'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
StandardError: GraphViz not installed or dot not in PATH. Install GraphViz or use the 'path' option
/home/bcc/.rvm/gems/ruby-2.2.3/gems/ruby-graphviz-1.2.2/lib/graphviz.rb:544:in `output'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram/graphviz.rb:200:in `block in <class:Graphviz>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `instance_eval'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:142:in `save'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:120:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/diagram.rb:74:in `create'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/rails_erd/tasks.rake:41:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/bcc/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:199:in `each'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:199:in `invoke_prerequisites'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/home/bcc/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:18:in `update_model'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rails-erd-1.4.5/lib/tasks/auto_generate_diagram.rake:3:in `block (2 levels) in <top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/bcc/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/home/bcc/.rvm/gems/ruby-2.2.3/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/rake:23:in `load'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/rake:23:in `<main>'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
/home/bcc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => erd => erd:generate

我不明白这个问题。将应用程序从 rails 3 升级到 rails 4.2 后,我遇到了这个问题。我的应用程序运行没有任何问题。但是当我运行rake db:migrate command 时,我得到了这个错误。如何解决这个问题?

错误日志中有一行可能很重要,但我不明白。

GraphViz not installed or dot not in PATH. Install GraphViz or use the 'path' option

【问题讨论】:

【参考方案1】:

Mac 用户:

brew install graphviz

【讨论】:

【参考方案2】:

试试下面的命令。

erd --inheritance --direct --attributes=foreign_keys,content --filetype=dot
dot -Tjpg erd.dot > erd.jpg

【讨论】:

安装 graphviz 对我没有用 - 上面有 太棒了,经过数小时的研究,这已经成功了 :) 谢谢并确保事先也进行 brew install graphviz!【参考方案3】:

这是因为您的项目正在使用Rails ERD,这是一个可以自动创建 ERD - 实体关系图的 gem。它依赖于一个名为graphviz 的库来运行。如果你想继续使用它,你必须installgraphviz。在 Linux 上,您可以通过控制台执行此操作:

sudo apt-get install graphviz

如果您不想使用 rails-erd gem,请将其从 Gemfile 和 bundle 中删除。如果您在 Gemfile 中没有看到它,请查看您的 Gemfile.lock 以确定需要 rails-erd gem 的内容并考虑删除该 gem。

【讨论】:

对我来说,即使安装了graphviz也不起作用

以上是关于保存图表失败!验证 Graphviz 是不是已安装并在您的路径中,或使用 filetype=dot的主要内容,如果未能解决你的问题,请参考以下文章

python中导入graphviz模块失败的解决办法

Graphviz安装配置教程(图文详解)

减小 graphviz 生成的图形的大小(如面积)

Keras:“运行时错误:导入 pydot 失败。”安装 graphviz 和 pydot 后

Pygraphviz 安装失败,错误代码 1083 无法打开文件 graphviz/cgraph.h:没有这样的文件或目录

VNote配置PlantUML和Graphviz