Well, my problem was a little different from yours, but I will post how I solved it if it helps the future Googler.
My problem was that I was getting the following error every time I tried to run rake stats :
rake aborted! ArgumentError: invalid byte sequence in UTF-8 /Users/george/.rvm/gems/ruby-2.1.5/gems/railties-4.1.6/lib/rails/code_statistics_calculator.rb:61:in `=~' /Users/george/.rvm/gems/ruby-2.1.5/gems/railties-4.1.6/lib/rails/code_statistics_calculator.rb:61:in `add_by_io' /Users/george/.rvm/gems/ruby-2.1.5/gems/railties-4.1.6/lib/rails/code_statistics_calculator.rb:43:in `block in add_by_file_path' ... # more stacktrace
So, I opened code_statistics_calculator.rb (file at the top of stacktrace and changed:
def add_by_file_path(file_path) File.open(file_path) do |f| self.add_by_io(f, file_type(file_path))
in
def add_by_file_path(file_path) File.open(file_path) do |f| begin self.add_by_io(f, file_type(file_path)) rescue ArgumentError debugger puts
Running rake stats again, I entered the debugger, and at that moment I could see that file_path was currently pointing to a specific file in app/models , which it could not parse as utf-8.
Of course, I opened this file in vim, and when I typed :set fileencoding? he returned latin-1 . So I set it to utf-8 ( set fileencoding=utf-8 , then saved the file) and of course rake stats works again! Voila.
(Please note that in your case there may be more than one file that is not in utf-8. Also, when you are done, make sure you remember to change code_statistics_calculator.rb back to your original form!)
source share