[Ruby] A story that an inexperienced beginner was having trouble setting up a Rails Server.

2 minute read

Nice to meet you. It is a bear. I will try to output the experiences that I had some troubles and were able to solve them.

Background

While recommending Progate’s Web development path, some parts of it went wrong, so I will share the solution I made. Since the content is soft and fluffy, I would appreciate any comments.

problem

STEP4 of Web development path (Ruby on Rails), [Let’s build environment of Ruby on Rails! (macOS)] will finally finish by setting up a Rails server in the browser. However, even if I enter a command in the editor, I cannot stand it! !! In particular

~
Could not find a JavaScript runtime.
~

The content was displayed and Rails could not be displayed in the browser. I didn’t have much experience with tampering with the terminal, so I googled the error code and found the following article.

  • [Rails s would get angry with Could not find a JavaScript runtime] (https://qiita.com/Thort/items/f7204832ea7bc704d677)

resolution

Apparently it’s talking about JavaScript. So when I googled “the ruby racer” in the error code, I found the following article.

For myself, who had no knowledge of building a development environment, I was able to continue learning without being depressed by seeing this article.

The point is that building a development environment is a demon. ruby has a library management system called rubygems. Rails requires a lot of libraries (gems) to be installed before booting, which often fails with irrational errors. Once you get used to it, you will understand the countermeasures, but I think that if you are a beginner, you have to do nothing.

As a content, the part called therubyracer is old, and the new part called mini_racer is widely used. → Somehow I was wondering if it might be related to JavaScript by technology from the front by connecting to Apple’s Sidecar and vehicle.

Implementation

When checking the contents of sample_app <Gemfile created in the lesson again, mini_racer is commented out… Can you uncomment this guy and save your edits? Update “bundle update”. After doing **“Rails s”, I was able to successfully launch Server in the browser.

Postscript

This time, I tried to write a solution to the problem for the first time, but I would like to reconsider the content of the gem and the consciousness of the flow line when the person who stumbles in the place with me temporarily refers to this article There were many improvements. I will continue to output like this in the future.