3

I am trying to rake erd to generate diagrams for models in my rails application. I am on windows 7 and graphviz is installed

When I run

rake erd OR rake erd filetype=dot

I am getting following error

$ 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

Did any one have experience with such issues ?

amjad
  • 2,876
  • 7
  • 26
  • 43

4 Answers4

9

I had the same problem on OS 10.9.2.

Solution

brew install graphviz

Create erd - working on Rails 4

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

You could also replace jpg with pdf

vladCovaliov
  • 4,333
  • 2
  • 43
  • 58
5

For Ubuntu users:

sudo apt-get install graphviz

MacOS

brew uninstall graphviz
brew install cairo
brew install pango
brew install graphviz
Abel
  • 3,989
  • 32
  • 31
  • Yes, the order is significant, see [this github issue](https://github.com/voormedia/rails-erd/issues/8#issuecomment-898957) – Epigene Feb 28 '19 at 13:00
0

Looks like this library swallows the underlying error see here

Can you edit the gem and print out the error message?

leifg
  • 8,668
  • 13
  • 53
  • 79
  • The path is here: c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-erd-1.1.0/lib/rails_erd/diagram/graphviz.rb, just edit that file – leifg Mar 13 '13 at 14:04
  • I am now getting following error after replacing the Gem file $ rake erd rake aborted! uninitialized constant RailsERD::Domain::Attribute::Inspectable – amjad Mar 13 '13 at 14:17
0

This could be as a result of no models in your rails application. Go to your app/model and make sure there are model files. If not, try to generate models and define their relationships.

Babatunde Mustapha
  • 2,131
  • 20
  • 21