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: <stdin>:1: syntax error near line 1 #41

Open hcientist opened 11 years ago

hcientist commented 11 years ago

When I run diagram:all, and then even just

rake diagram:models:brief

I get an error:

rake diagram:models:brief
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
Generating /wherever/doc/models_brief.svg
railroady -bilamM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | dot -Tsvg > /wherever/doc/models_brief.svg
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
Error: <stdin>:1: syntax error near line 1
context:   >>>   (0.4ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" 
Warning: <stdin>:1: ambiguous "1m" splits into two names: "1" and "m"
Warning: <stdin>:1: ambiguous "36m" splits into two names: "36" and "m"
Warning: <stdin>:1: ambiguous "0.4ms" splits into two names: "0.4" and "ms"
Warning: <stdin>:1: ambiguous "0m" splits into two names: "0" and "m"
Warning: <stdin>:1: ambiguous "1mSELECT" splits into two names: "1" and "mSELECT"
Warning: <stdin>:1: ambiguous "0m" splits into two names: "0" and "m"
rake aborted!
Command failed with status (1): [railroady -bilamM | sed -E 's/\x1B\[([0-9]...]

Tasks: TOP => diagram:models:brief
(See full trace by running task with --trace)

so with trace,

rake diagram:models:brief --trace
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
** Invoke diagram:models:brief (first_time)
** Execute diagram:models:brief
Generating /wherever/doc/models_brief.svg
railroady -bilamM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | dot -Tsvg > /wherever/doc/models_brief.svg
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
Error: <stdin>:1: syntax error near line 1
context:   >>>   (0.6ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" 
Warning: <stdin>:1: ambiguous "1m" splits into two names: "1" and "m"
Warning: <stdin>:1: ambiguous "36m" splits into two names: "36" and "m"
Warning: <stdin>:1: ambiguous "0.6ms" splits into two names: "0.6" and "ms"
Warning: <stdin>:1: ambiguous "0m" splits into two names: "0" and "m"
Warning: <stdin>:1: ambiguous "1mSELECT" splits into two names: "1" and "mSELECT"
Warning: <stdin>:1: ambiguous "0m" splits into two names: "0" and "m"
rake aborted!
Command failed with status (1): [railroady -bilamM | sed -E 's/\x1B\[([0-9]...]
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@rails322Platypus/gems/railroady-1.1.0/tasks/railroady.rake:62:in `block (3 levels) in <top (required)>'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/MYUSER/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/bin/rake:19:in `load'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@global/bin/rake:19:in `<main>'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@rails322Platypus/bin/ruby_noexec_wrapper:14:in `eval'
/MYUSER/.rvm/gems/ruby-1.9.3-p125@rails322Platypus/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => diagram:models:brief

Any suggestions? Thanks for your hard work on this.

brianpetro commented 11 years ago

Same issue with Ruby 2. Error: <stdin>:1: syntax error near line 1 pointed me to Graphviz as the source of the issue.

$ rake diagram:all --trace
** Invoke diagram:all (first_time)
** Invoke diagram:models:complete (first_time)
** Execute diagram:models:complete
Generating /home/brian/Dropbox/apps/hh/doc/models_complete.svg
railroady -ilamM | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | dot -Tsvg > /home/brian/Dropbox/apps/hh/doc/models_complete.svg
Error: <stdin>:1: syntax error near line 1
context:    >>>  ( <<< 1.0ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" 
Warning: <stdin>:1: ambiguous "1.0ms" splits into two names: "1.0" and "ms"
rake aborted!
Command failed with status (1): [railroady -ilamM | sed -r 's/\x1B\[([0-9]{...]
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/file_utils.rb:54:in `block in create_shell_runner'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `call'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `sh'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `sh'
/home/brian/.rvm/gems/ruby-2.0.0-p247/gems/railroady-1.1.1/tasks/railroady.rake:55:in `block (3 levels) in <top (required)>'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/brian/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/home/brian/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `load'
/home/brian/.rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `<main>'
/home/brian/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
/home/brian/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => diagram:all => diagram:models:complete```
olleolleolle commented 10 years ago

Ah, my problem seems to be something like this: what is being output by railroady has a bad starting line. If we can get rid of that, we are good to go.

(snipped output)

Generating DOT graph
   (0.6ms)  SELECT "schema_migrations"."version" FROM "schema_migrations"
digraph models_diagram {
    graph[overlap=false, splines=true]
    _diagram_info [shape="plaintext", label="Models diagram\lDate: Mar 15 2014 - 17:41\lMigration version: 20140313101846\lGenerated by RailRoady 1.1.1\lhttp://railroady.prestonlee.com\l", fontsize=13]

(snipped...)

This was runnable:

railroady -ilamM | grep -v schema_migrations | dot -Tsvg > doc/models_complete.svg

So, my final script for my Jenkins job to do this became:

#!/bin/bash
set -e

# initialize rbenv
source ~/.bash_profile

function railroad_diagram {
  foreman run -e .env_test railroady $1 | grep -v schema_migrations 
}
function railroad_diagram_models {
  railroad_diagram "-ilamM"  | dot -T$1 > doc/models_complete.$1
  railroad_diagram "-bilamM" | dot -T$1 > doc/models_brief.$1
}
function railroad_diagram_controllers {
  railroad_diagram "-ilC"  | dot -T$1 > doc/controllers_complete.$1
  railroad_diagram "-bilC" | dot -T$1 > doc/controllers_brief.$1
}

for diagram_format in svg png; do
  railroad_diagram_models $diagram_format
  railroad_diagram_controllers $diagram_format
done
evadne commented 10 years ago

Ran into a similar situation. Added this to environment.rb:

if $0 =~ /(rake|railroady|erd)$/
  Rails.logger = Logger.new("/dev/null")
end
ocolot commented 10 years ago

Same issue here with ruby 2.1.2p95. @evadne solution didn't work :(

evadne commented 10 years ago

@ocolot You just need to hook the logger and see if when railroady is running it’s getting irrelevant lines, and nil the offending loggers.

thromera commented 9 years ago

Same problem here w/ ruby 2.0.0p481 , @evadne solution didn't work.

daino3 commented 9 years ago

@olleolleolle :+1:

benlieb commented 7 years ago

I had a similar issue and found that the first part of the pipe sequence:

railroady -lamM | sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | ...

this bit:

railroady -lamM

had extraneous input above what railroady was expecting would come out.

In my case I like to see SQL in my logs in dev and had this line in my development.rb:

ActiveRecord::Base.logger = Logger.new(STDOUT) #show queries in console

And that was logging some db queries into the roady output.

Using @evadne 's recommendation I put this in my development.rb and all is now well:


unless $0 =~ /(rake|railroady|erd)$/
  ActiveRecord::Base.logger = Logger.new(STDOUT) #show queries in console
end
PedroGFonseca commented 6 years ago

I get that problem when there is a forbidden character somewhere in any names. For the specific case of using it in decision trees, this generally fixes it for me:

def make_safe(name): 
    for char in suspect:
        name = name.replace(char, '', )        
    return name 

suspect = [',', '_', ':', ';', ']', '[', '&', "\'", "\"", '-', '/', '', '+', '_', '<', '>', '(', ')']
col_names = [make_safe(c) for c in list(X_train.columns)]

Would be great if the error were clearer as to where the problem is though.