ruby 失败:运行时错误:保存逻辑示意图失败!运行rake erd命令时

hjzp0vay  于 2022-11-22  发布在  Ruby
关注(0)|答案(4)|浏览(139)

我正在尝试rake erd来为我的rails应用程序中的模型生成图。我在windows 7上并且安装了graphviz
当我奔跑

rake erd OR rake erd filetype=dot

出现以下错误

$ rake erd --trace
** 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 (first_time)
** Execute environment
Loading code in search of Active Record models...
** Execute erd:generate
Generating Entity-Relationship Diagram for 6 models...
rake aborted!
Saving diagram failed!
Verify that Graphviz is installed and in your path, or use filetype=dot.
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/diagram/graphviz.rb:198:in `r
escue in block in <class:Graphviz>'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/diagram/graphviz.rb:190:in `b
lock in <class:Graphviz>'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/diagram.rb:142:in `instance_e
val'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/diagram.rb:142:in `save'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/diagram.rb:120:in `create'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/diagram.rb:74:in `create'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/tasks.rake:41:in `block (2 le
vels) in <top (required)>'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_c
all_chain'
c:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain
'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prereq
uisites'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_c
all_chain'
c:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain

有没有人遇到过这样的问题?

3yhwsihp

3yhwsihp1#

我在OS 10.9.2上遇到了同样的问题。

解决方案

brew install graphviz

创建erd -使用Rails 4

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

您也可以将jpg替换为pdf

ghhaqwfi

ghhaqwfi2#

对于Ubuntu用户:

sudo apt-get install graphviz

Mac操作系统

brew uninstall graphviz
brew install cairo
brew install pango
brew install graphviz
pbpqsu0x

pbpqsu0x3#

这可能是因为您的rails应用程序中没有模型。请转到您的app/model并确保存在模型文件。如果没有,请尝试生成模型并定义它们的关系。

jexiocij

jexiocij4#

看起来此库吞入了底层错误请参见此处
您可以编辑gem并打印出错误消息吗?

相关问题