Debugging JSON::ParserError during Rake clean task

Figured I’d post this here since it could help others once we figure it out.

I’m seeing an issue for upgrading from 1.4.3 to 1.4.4 - basically, I’m seeing a JSON::ParserError during a run of assets:clean in preparation for an assets:precompile. (The same error is there for precompile as well.)

How do you go about debugging this error? I’ve tried completely re-setting up my Rails environment in case there was something wrong with how I updated stuff- no dice.

Here’s the full output of the command:

$ RAILS_ENV=production  bundle exec rails assets:clean --trace
** Invoke assets:clean (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rails aborted!
 JSON::ParserError: 743: unexpected token at ''
 /home/mastodon/.rbenv/versions/2.4.1/lib/ruby/2.4.0/json/common.rb:156:in `parse'
...
bin/rails:4:in `<main>'
Tasks: TOP => environment

EDIT: I’ve encountered a variety of GitHub issues I’m looking into that relate to this error:

https://github.com/tootsuite/mastodon/issues/2911
https://github.com/tootsuite/mastodon/issues/3251
https://github.com/tootsuite/mastodon/issues/3788

It’s possible I needed to manually clear something that got corrupted out of the assets folder manually- but I ran a manual webpack build and it appears to have cleared out my problem as I can now call the assets:precompile command without error.

For context, the specific command I called to run the webpack is:

NODE_ENV=production ./node_modules/.bin/webpack --config config/webpack/production.js

Also you can do that by following command:

yarn run build:production
1 Like