Open hcientist opened 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```
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
Ran into a similar situation. Added this to environment.rb
:
if $0 =~ /(rake|railroady|erd)$/
Rails.logger = Logger.new("/dev/null")
end
Same issue here with ruby 2.1.2p95. @evadne solution didn't work :(
@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.
Same problem here w/ ruby 2.0.0p481 , @evadne solution didn't work.
@olleolleolle :+1:
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
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.
When I run
diagram:all
, and then even justI get an error:
so with trace,
Any suggestions? Thanks for your hard work on this.