Error: ArgumentError; message invalid byte sequence in US-ASCII. Failed evaluating erb template for section report and template
mszyndel opened this issue · 6 comments
When I run metric_fu with ANY metrics enabled I always get following error
******* SAVING REPORTS
/Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/metrics/base_template.rb:41:in `rescue in erbify': Error: ArgumentError; message invalid byte sequence in US-ASCII. Failed evaluating erb template for section report and template /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/templates/report.html.erb. (RuntimeError)
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/metrics/base_template.rb:34:in `erbify'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/templates/report.rb:15:in `render'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/reporting/templates/awesome/awesome_template.rb:48:in `block in write_file_data'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/reporting/templates/awesome/awesome_template.rb:45:in `each_pair'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/reporting/templates/awesome/awesome_template.rb:45:in `write_file_data'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/reporting/templates/awesome/awesome_template.rb:41:in `write'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/formatter/html.rb:56:in `save_templatized_result'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/formatter/html.rb:24:in `finish'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/reporter.rb:33:in `block in notify'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/reporter.rb:32:in `each'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/reporter.rb:32:in `notify'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/reporter.rb:12:in `finish'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/run.rb:22:in `measure'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/run.rb:8:in `run'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/cli/helper.rb:18:in `run'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/lib/metric_fu/cli/client.rb:18:in `run'
from /Users/michal/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/metric_fu-4.10.0/bin/metric_fu:9:in `<top (required)>'
from /Users/michal/.rbenv/versions/1.9.3-p448/bin/metric_fu:23:in `load'
from /Users/michal/.rbenv/versions/1.9.3-p448/bin/metric_fu:23:in `<main>'
This doesn't happen if I disable all the metrics (with --no-...
) or change format to yaml.
$ metric_fu --debug-info
{"Ruby"=>
{"Engine"=>"ruby",
"Version"=>"1.9.3",
"Patchlevel"=>448,
"Ripper Support"=>true,
"Rubygems Version"=>"1.8.23",
"Long Description"=>
"ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin13.0.0]"},
"Environment"=>
{"VERBOSE"=>"false",
"External Encoding"=>"US-ASCII",
"Internal Encoding"=>"",
"Host Architecture"=>"x86_64-apple-darwin13.0.0",
"Ruby Prefix"=>"/Users/michal/.rbenv/versions/1.9.3-p448",
"Ruby Options"=>""},
"MetricFu"=>
{"Version"=>"4.10.0",
"Verbose Mode"=>false,
"Enabled Metrics"=>
[:cane,
:churn,
:flay,
:flog,
:stats,
:saikuro,
:reek,
:roodi,
:rails_best_practices,
:hotspots],
"Dependencies"=>
[{"name"=>"flay", "version"=>"2.4.0"},
{"name"=>"churn", "version"=>"0.0.35"},
{"name"=>"flog", "version"=>"4.2.0"},
{"name"=>"reek", "version"=>[">= 1.3.4", "~> 1.3"]},
{"name"=>"cane", "version"=>"2.6.1"},
{"name"=>"rails_best_practices", "version"=>"1.15.2"},
{"name"=>"saikuro", "version"=>[">= 1.1.3", "~> 1.1"]},
{"name"=>"roodi", "version"=>"3.3.1"},
{"name"=>"code_metrics", "version"=>"0.1.3"},
{"name"=>"redcard", "version"=>"1.1.0"},
{"name"=>"coderay", "version"=>"1.1.0"},
{"name"=>"multi_json", "version"=>"1.9.2"},
{"name"=>"rcov", "version"=>["~> 0.8"]}]}}
Are you able to install from the read_report_in_binary
branch? Or produce a failing test?
When I tried to install this branch I got US-ASCII error from Bundler. After some googling it turns out, that it's Mac-specific problem and can be solved by exporting this to env:
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
Now I can install and run gem without any problems.
Maybe it would be nice to add an info for Mac users after installation (or maybe even only when those env vars are not set?)
Oh, weird. I thought it might be some external encoding thing. This should probably go in an FAQ. Would you mind updating the wiki? (I tried writing some tests for this but was unable to duplicate).
Good job Michael 👍
@hajder 👍