preston / railroady

Ruby on Rails 3/4/5 model and controller UML class diagram generator. (`brew/port/apt-get install graphviz` before use!)
Other
1.71k stars 142 forks source link

Error while trying to run rake task #104

Open luizs81 opened 8 years ago

luizs81 commented 8 years ago

ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14] Rails 4.1.11

rake diagram:all --trace
** Invoke diagram:all (first_time)
** Invoke diagram:setup:create_new_doc_folder_if_needed (first_time)
** Execute diagram:setup:create_new_doc_folder_if_needed
** Invoke diagram:models:complete (first_time)
** Execute diagram:models:complete
Generating /Users/luiz/prott-api/doc/models_complete.svg
railroady -lamM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | dot -Tsvg > /Users/luiz/prott-api/doc/models_complete.svg
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-rewrite-1.5.0/lib/rack/rewrite/rule.rb:172: warning: duplicated key at line 173 ignored: "Content-Type"
Error: <stdin>: syntax error in line 1 near 'W'
Warning: syntax ambiguity - badly delimited number '-03T' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '-03T' in line 2 of <stdin> splits into two tokens
rake aborted!
Command failed with status (1): [railroady -lamM | sed -E 's/\x1B\[([0-9]{1...]
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/file_utils.rb:66:in `block in create_shell_runner'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/file_utils.rb:57:in `call'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/file_utils.rb:57:in `sh'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/file_utils_ext.rb:37:in `sh'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railroady-1.4.2/tasks/railroady.rake:64:in `block (3 levels) in <top (required)>'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:199:in `each'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/local/var/rbenv/versions/2.2.2/bin/rake:33:in `<main>'
Tasks: TOP => diagram:all => diagram:models:complete
preston commented 8 years ago

Could you try running the command string manually from the command line and see if that helps to troubleshoot? This doesn't look familiar.

tuexss commented 8 years ago

I'm getting the same, even from directly triggering it:

railroady -lamM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | dot -Tsvg > /somepath/doc/models_complete.svg
Error: <stdin>: syntax error in line 1 near '
Warning: syntax ambiguity - badly delimited number '1m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '36m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '1.2m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '0m' in line 1 of <stdin> splits into two tokens
...

Graphviz doesn't like digits in the beginning.

lastobelus commented 8 years ago

I am getting similar errors (using brew graphviz 2.38.0_1)

rake diagram:all --trace
bundle exec rake diagram:all --trace:
** Invoke diagram:all (first_time)
** Invoke diagram:setup:create_new_doc_folder_if_needed (first_time)
** Execute diagram:setup:create_new_doc_folder_if_needed
** Invoke diagram:models:complete (first_time)
** Execute diagram:models:complete
Generating /Users/lasto/clients/webify/teesforthepeople-api/doc/models_complete.svg
railroady -lamM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | dot -Tsvg > /Users/lasto/clients/webify/teesforthepeople-api/doc/models_complete.svg
/Users/lasto/clients/webify/teesforthepeople-api/app/models/lab_color.rb:3: warning: already initialized constant LabColor
/Users/lasto/clients/webify/teesforthepeople-api/app/models/lab_color.rb:3: warning: previous definition of LabColor was here
Error: <stdin>: syntax error in line 1 near 'D'
Warning: syntax ambiguity - badly delimited number '-28T' in line 1 of <stdin> splits into two tokens
rake aborted!
Command failed with status (1): [railroady -lamM | sed -E 's/\x1B\[([0-9]{1...]
/Users/lasto/.rvm/gems/ruby-2.2.5@tees/gems/rake-11.2.2/lib/rake/file_utils.rb:69:in `block in create_shell_runner'
/Users/lasto/.rvm/gems/ruby-2.2.5@tees/gems/rake-11.2.2/lib/rake/file_utils.rb:59:in `call'
/Users/lasto/.rvm/gems/ruby-2.2.5@tees/gems/rake-11.2.2/lib/rake/file_utils.rb:59:in `sh'
/Users/lasto/.rvm/gems/ruby-2.2.5@tees/gems/rake-11.2.2/lib/rake/file_utils_ext.rb:37:in `sh'
/Users/lasto/.rvm/gems/ruby-2.2.5@tees/gems/railroady-1.5.1/tasks/railroady.rake:64:in `block (3 levels) in <top (required)>'
mattlindsey commented 8 years ago

Also on: ruby-2.3.1 rails 4.2.6

rake diagram:all_with_engines
Generating /Users/mattlindsey/Documents/github/redeemify/doc/models_complete.svg
railroady -ilamzM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | dot -Tsvg > /Users/mattlindsey/Documents/github/redeemify/doc/models_complete.svg
Error: <stdin>: syntax error in line 1 near '
Warning: syntax ambiguity - badly delimited number '1m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '36m' in line 1 of <stdin> splits into two tokens
tansaku commented 8 years ago

I see this too - funny - it works for me in some rails projects but not others ... here's me splitting the command into three components:

tansaku@Samuels-MacBook-Pro:~/Documents/GitHub/StrawberryCanyon/redeemify (master)]$ 
→ railroady -lamM
  ActiveRecord::SchemaMigration Load (0.3ms)  SELECT "schema_migrations".* FROM "schema_migrations"
digraph models_diagram {
    graph[overlap=false, splines=true, bgcolor="none"]
    _diagram_info [shape="plaintext", label="Models diagram\lDate: Nov 01 2016 - 17:46\lMigration version: 20161030143818\lGenerated by RailRoady 1.5.1\lhttp://railroady.prestonlee.com\l", fontsize=13]
    "AdminUser" [shape=Mrecord, label="{AdminUser|updated_at :timestamp without time zone\lemail :character varying\lencrypted_password :character varying\lreset_password_token :character varying\lreset_password_sent_at :timestamp without time zone\lremember_created_at :timestamp without time zone\lsign_in_count :integer\lcurrent_sign_in_at :timestamp without time zone\llast_sign_in_at :timestamp without time zone\lcurrent_sign_in_ip :character varying\llast_sign_in_ip :character varying\lcreated_at :timestamp without time zone\lid :integer\l}"]
    "Provider" [shape=Mrecord, label="{Provider|removedCodes :integer\lname :character varying\lhistory :character varying\lprovider :character varying\lemail :character varying\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\lusedCodes :integer\luploadedCodes :integer\lunclaimCodes :integer\lid :integer\l}"]
    "RedeemifyCode" [shape=Mrecord, label="{RedeemifyCode|email :character varying\lname :character varying\lcode :character varying\luser_id :integer\lprovider_id :integer\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\luser_name :character varying\lid :integer\l}"]
    "User" [shape=Mrecord, label="{User|email :character varying\lprovider :character varying\luid :character varying\lname :character varying\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\lcode :character varying\lid :integer\l}"]
    "Vendor" [shape=Mrecord, label="{Vendor|removedCodes :integer\lname :character varying\luid :character varying\lprovider :character varying\ldescription :character varying\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\lemail :character varying\lhistory :character varying\lwebsite :character varying\linstruction :character varying\lhelpLink :character varying\lcashValue :character varying\lexpiration :character varying\lusedCodes :integer\luploadedCodes :integer\lunclaimCodes :integer\lid :integer\l}"]
    "VendorCode" [shape=Mrecord, label="{VendorCode|email :character varying\lcode :character varying\lvendor :character varying\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\lvendor_id :integer\luser_id :integer\lname :character varying\luser_name :character varying\lid :integer\l}"]
    "Provider" -> "RedeemifyCode" [arrowtail=odot, arrowhead=crow, dir=both color="#DBBD5C"]
    "User" -> "VendorCode" [arrowtail=odot, arrowhead=crow, dir=both color="#14C14F"]
    "Vendor" -> "VendorCode" [arrowtail=odot, arrowhead=crow, dir=both color="#332BBB"]
}
[tansaku@Samuels-MacBook-Pro:~/Documents/GitHub/StrawberryCanyon/redeemify (master)]$ 
→ railroady -lamM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g'
  ActiveRecord::SchemaMigration Load (0.4ms)  SELECT "schema_migrations".* FROM "schema_migrations"
digraph models_diagram {
    graph[overlap=false, splines=true, bgcolor="none"]
    _diagram_info [shape="plaintext", label="Models diagram\lDate: Nov 01 2016 - 17:47\lMigration version: 20161030143818\lGenerated by RailRoady 1.5.1\lhttp://railroady.prestonlee.com\l", fontsize=13]
    "AdminUser" [shape=Mrecord, label="{AdminUser|updated_at :timestamp without time zone\lemail :character varying\lencrypted_password :character varying\lreset_password_token :character varying\lreset_password_sent_at :timestamp without time zone\lremember_created_at :timestamp without time zone\lsign_in_count :integer\lcurrent_sign_in_at :timestamp without time zone\llast_sign_in_at :timestamp without time zone\lcurrent_sign_in_ip :character varying\llast_sign_in_ip :character varying\lcreated_at :timestamp without time zone\lid :integer\l}"]
    "Provider" [shape=Mrecord, label="{Provider|removedCodes :integer\lname :character varying\lhistory :character varying\lprovider :character varying\lemail :character varying\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\lusedCodes :integer\luploadedCodes :integer\lunclaimCodes :integer\lid :integer\l}"]
    "RedeemifyCode" [shape=Mrecord, label="{RedeemifyCode|email :character varying\lname :character varying\lcode :character varying\luser_id :integer\lprovider_id :integer\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\luser_name :character varying\lid :integer\l}"]
    "User" [shape=Mrecord, label="{User|email :character varying\lprovider :character varying\luid :character varying\lname :character varying\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\lcode :character varying\lid :integer\l}"]
    "Vendor" [shape=Mrecord, label="{Vendor|removedCodes :integer\lname :character varying\luid :character varying\lprovider :character varying\ldescription :character varying\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\lemail :character varying\lhistory :character varying\lwebsite :character varying\linstruction :character varying\lhelpLink :character varying\lcashValue :character varying\lexpiration :character varying\lusedCodes :integer\luploadedCodes :integer\lunclaimCodes :integer\lid :integer\l}"]
    "VendorCode" [shape=Mrecord, label="{VendorCode|email :character varying\lcode :character varying\lvendor :character varying\lcreated_at :timestamp without time zone\lupdated_at :timestamp without time zone\lvendor_id :integer\luser_id :integer\lname :character varying\luser_name :character varying\lid :integer\l}"]
    "Provider" -> "RedeemifyCode" [arrowtail=odot, arrowhead=crow, dir=both color="#D3E424"]
    "User" -> "VendorCode" [arrowtail=odot, arrowhead=crow, dir=both color="#695F0C"]
    "Vendor" -> "VendorCode" [arrowtail=odot, arrowhead=crow, dir=both color="#D4B48C"]
}
[tansaku@Samuels-MacBook-Pro:~/Documents/GitHub/StrawberryCanyon/redeemify (master)]$ 
→ railroady -lamM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | dot -Tsvg
Error: <stdin>: syntax error in line 1 near '
Warning: syntax ambiguity - badly delimited number '1m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '36m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '0.4m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '0m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '1m' in line 1 of <stdin> splits into two tokens
Warning: syntax ambiguity - badly delimited number '0m' in line 1 of <stdin> splits into two tokens```

funny thing is that the tokens it is complaining about don't appear in the last stage of the output ...
mattlindsey commented 8 years ago

Clue. Something in the Railroady code seems to be outputting this line first, which causes dot to fail:

^[[1m^[[36mActiveRecord::SchemaMigration Load (0.6ms)^[[0m  ^[[1mSELECT "schema_migrations".* FROM "schema_migrations"^[[0m
marnen commented 7 years ago

116 should fix this.

roeintense commented 7 years ago

I am running in to this issue as well. Some work, some don't, like @tansaku says.

marnen commented 7 years ago

@roeintense Right, it depends on Rails logging and maybe some other settings. Try the fork in #116 (could we please get that merged?).

joelvh commented 7 years ago

Seems this all relates to ActiveRecord logging. Simple solution that worked for me was to set the ActiveRecord logger to nil in config/environments/development.rb when running railroady:

Rails.application.configure do

  config.log_level = :debug

  config.active_record.logger = Logger.new(STDOUT)
  config.active_record.logger.level = config.log_level

  if $0 =~ /(rake|railroady|erd)$/
    config.active_record.logger = nil
  end

end
marnen commented 7 years ago

@joelvh Please see #116, which essentially does the same thing without resorting to parsing the command line.

joelvh commented 7 years ago

@marnen once that's merged, it may help. However, if there is an AR logger and the log level is debug, there will still be artifacts interfering with the output piped to the other commands.

marnen commented 7 years ago

@joelvh Are you saying that AR logging in Rails doesn't necessarily come through the Rails logger? That's the only case I could think of in which your last comment would be accurate.

preston commented 7 years ago

Are folks ok with merging in PR #116?

kimroen commented 7 years ago

Output from logging is what is tripping it up for me as well, so silencing the logger seems like an okay solution.