magic-commenter Install and execute: $ [sudo] gem install magic-commenter $ magic-commenter It will iterate through all your .rb and .rake files and add utf8 magic comment if the paring fails with a multibyte error.