2013-03-13 143 views
1

我想耙erd生成模型在我的rails應用程序的圖。我對Windows 7和graphviz的安裝失敗:RuntimeError:保存圖失敗!當運行耙erd命令

當我運行

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 

沒有任何一個有這類問題的經驗?

回答

0

貌似這個庫燕子的底層錯誤see here

你能編輯的寶石,並打印出錯誤消息?

+0

我怎麼可以編輯的寶石? – amjad 2013-03-13 13:55:25

+0

路徑在這裏:c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/diagram/graphviz.rb,只需編輯該文件 – leifg 2013-03-13 14:04:31

+0

我現在正在更換Gem文件後發生錯誤$ rake erd rake中止! 未初始化的常量RailsERD :: Domain :: Attribute :: Inspectable – amjad 2013-03-13 14:17:42

9

我在OS 10.9.2上遇到了同樣的問題。

解決方案

brew install graphviz 

創建ERD - on Rails的工作4

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

你也可以用PDF

3

更換JPG對於Ubuntu用戶:

sudo apt-get install graphviz 

的MacOS

brew uninstall graphviz 
brew install cairo 
brew install pango 
brew install graphviz 
+1

謝謝,亞伯。 brew安裝graphviz爲我工作。 – Jagdish 2017-05-18 09:26:58