rake aborted! JSON::GeneratorError: source sequence is illegal/malformed utf-8 after rake assets:precompile

后端 未结 1 1802
清酒与你
清酒与你 2021-01-19 03:52

I finished building a website and want to deploy it to Digital Ocean VPN. Installed Capistrano and Passenger. During initial deployment I was receiving an error that apparen

1条回答
  •  粉色の甜心
    2021-01-19 04:27

    I encountered the exactly same error message. With that telltale, I googled "check if a file is valid utf-8" and found isutf8(1): check whether files are valid UTF-8 - Linux man page. So I installed isutf8 and then ran the following command from the Rails root on my linux machine

    isutf8 `find app`
    

    Although there are lots of noise in the output, it tells me that app/assets/javascripts/filterbar.js: line 1, char 1, byte offset 41: invalid UTF-8 code. So I opened that file. Viola! I saw a few garbled characters. Once I removed those characters, my rake assets:precompile succeeded. The actual guilty file of yours might be different, of course. You can also use other utility to check utf-8 such as in this stackoverflow question on utf-8, of course.

    0 讨论(0)
提交回复
热议问题