Search code examples
utf-8rakeruby-on-rails-4.2

rake notes hits utf-8 error


running rake notes is hitting an invalid byte sequence in UTF-8 but even with trace turned on, does not point to any offending file, just items in the ruby version and railties 4.2.4 directories.

Manually removing all the notes and stashing them does not change the behaviour. Is there any way to determine where this character is stopping the process?


Solution

  • The following run within the directory of choice

    find . -type f | xargs -I {} bash -c "iconv -f utf-8 -t utf-16 {} &>/dev/null || echo {}" > utf8_fail
    

    will generate a file of all failing items. Then iterate through all culprits ending in .builder, .rb, .erb, .haml and .slim to find the guilty party/ies

    fwiw, mine was a nasty alias created by OS X that bloated to 1.1 MB