[RUBY] 767 JSON :: ParserError occurs and the problem that the local server cannot be started

767 JSON :: ParserError occurs and the problem that the local server cannot be started

When entering the rails s command on the terminal, The following error log occurred during the server startup process, and the local server startup failed.

#Lines above the 10th line are omitted
	10: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
	 9: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:61:in `block in run_initializers'
	 8: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `run'
	 7: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `instance_exec'
	 6: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/webpacker-4.3.0/lib/webpacker/railtie.rb:84:in `block in <class:Engine>'
	 5: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/webpacker-4.3.0/lib/webpacker.rb:35:in `bootstrap'
	 4: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/webpacker-4.3.0/lib/webpacker/commands.rb:25:in `bootstrap'
	 3: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/webpacker-4.3.0/lib/webpacker/manifest.rb:18:in `refresh'
	 2: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/webpacker-4.3.0/lib/webpacker/manifest.rb:84:in `load'
	 1: from /Users/ito/.rbenv/versions/2.6.5/lib/ruby/2.6.0/json/common.rb:156:in `parse'
/Users/ito/.rbenv/versions/2.6.5/lib/ruby/2.6.0/json/common.rb:156:in `parse': 767: unexpected token at '' (JSON::ParserError)

When I read the error content for the time being, parse': 767: unexpected token at '' (JSON::ParserError) Pay attention to the display of. What the hell is this? I think, I will continue to search for a solution.

What was investigated and hypothesis

For the time being, I searched with JSON :: ParserError, but I couldn't find any information about it. Meanwhile, the information on the following site became a source of light.

Developer mode blog: rails 6 wasting precious 4 hours in the afternoon

... I'm falling here. When I followed it, there was a file called manifest.json under public / packs, which was empty. I must have gone to make this file when it got stuck. I forced a reset there, so it remained empty, which seems to give a JSON-ParseError. I deleted this file and it worked. Was good.

Hmmm, in short ** the file for ruby itself is corrupted ** and ... In retrospect, I remembered ** killing the server with Control + C while processing the local server **. As with the above symptoms, hypothesize that ** manifest.rb may have been corrupted **, I tried to save manifest.rb to another directory (such as desktop) so that it would not be read.

as a result

Based on the hypothesis and the contents investigated, save manifest.rb to another directory (desktop) and execute rails s again. Then, the following result was returned.

Terminal


/Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:
in `require': cannot load such file -- 
/Users/ito/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/webpacker-4.3.0/lib/webpacker/manifest.rb (LoadError)

... Well, I thought it would be like this, but I was shocked to run into the dark grounding again here. It seems that it was not solved without loading manifest.rb. ~~ It doesn't seem to be automatically generated in the first place ~~

I couldn't find a valid solution on the internet anymore, so I decided to ask a question to the mentor of TECK CAMP. It is impossible to solve the error occurring in the unknown dark area by yourself.

But ..., no ...!

It was a bug whose solution was unknown to the mentor. I'm sorry to have done various things, but the operation of my Mac Book became too heavy, so I took a break here. It's already Yannarune.

And the solution

Looking back at the contents of Developer mode blog: rails 6 wasting precious 4 hours in the afternoon View.

・ ・ ・ ** There is a file called manifest.json ** under public / packs ...

**Hmm? ** If you look closely, you haven't said a word to delete manifest.rb!

Then check the directory immediately. There is an empty manifest.rb ...! Delete manifest.rb while wkwk. As a result, the local server has been successfully revived. Congratulations

The cause was ** the manifest.json ** in the public / packs directory of the Rails app I'm working on. I wonder why I overlook it because it was written in the reference blog. The Ruby file wasn't corrupted.

I was terrified by my self-confidence reading comprehension, and this solved the 767 JSON :: ParserError. I wasted 3 hours ... I don't use Control + C lightly anymore ...

Recommended Posts

767 JSON :: ParserError occurs and the problem that the local server cannot be started
About the problem that the server can not be started with rails s
Rails server cannot be started in Cloud9
How to solve the problem that notification cannot be requested on iOS14
Solves the problem that SwiftPM cannot cross the proxy and cannot add packages to the project
[Android] Solution when the camera cannot be started on Android 9
JSON in Java and Jackson Part 1 Return JSON from the server
Avoid the problem that session cannot be acquired when canary release when upgrading from Rails 4.2.x to 5.0.x
Lenovo ThinkPad T14 Gen1 How to solve the problem that the speaker becomes dummy and cannot be used when installing Ubuntu 20.04 on AMD
"ClassNotFoundException" is displayed when tomcat is started in eclipse and cannot be started
A story that addresses the problem that REMOTE_ADDR cannot be acquired in a cluster built with Docker Swarm + Traefik (1.7).
How to erase the process ID (PID) that cannot be erased! (Handling inoperability with Vim and Vi)
Pg_resetwal can be used to start the PostgreSQL Docker container when WAL is broken and cannot be started.