Railsチュートリアル：Rails Serverができないエラーへの対処

[Railsチュートリアル](https://railstutorial.jp/chapters/beginning?version=5.1#sec-rails_server)の第1章、
1.3.2 rails server
のところで、同じように
`$ rails server`
しようとすると、なぜか下記のエラーを吐いてしまい、サーバーが立ち上がらなかった。

```
R0229-MacBook-Pro:hello_app r0229$ rails s
/Users/r0229/dev/hello_app/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError)
	from /Users/r0229/dev/hello_app/config/boot.rb:4:in `<top (required)>'
	from /Users/r0229/dev/hello_app/bin/rails:8:in `require_relative'
	from /Users/r0229/dev/hello_app/bin/rails:8:in `<top (required)>'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /Users/r0229/dev/hello_app/bin/spring:15:in `<top (required)>'
	from bin/rails:3:in `load'
	from bin/rails:3:in `<main>'
```
「bootsnapがない！」とエラーで言われております。

チュートリアル通りにやっているので「知らんがな」と思いつつ、

```
gem 'bootsnap'
```

をGemfileに追加しました。

`$ bundle install`
`$ rails s`

を実施すると別のエラーが・・・

```
R0229-MacBook-Pro:hello_app r0229$ rails s
/Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/application/configuration.rb:81:in `load_defaults': Unknown version "5.2" (RuntimeError)
	from /Users/r0229/dev/hello_app/config/application.rb:12:in `<class:Application>'
	from /Users/r0229/dev/hello_app/config/application.rb:10:in `<module:HelloApp>'
	from /Users/r0229/dev/hello_app/config/application.rb:9:in `<main>'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:133:in `block in perform'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `tap'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `perform'
	from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
	from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
	from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<main>'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
	from /Users/r0229/dev/hello_app/bin/rails:9:in `<top (required)>'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /Users/r0229/dev/hello_app/bin/spring:15:in `<top (required)>'
	from bin/rails:3:in `load'
	from bin/rails:3:in `<main>'
```

よくわからないのだが、configuration.rbにて、「5.2じゃないよ」と言われている。
確かにrailsは、5.16でダウンロードしている。

そこで

config > application.rb
にて

```
    config.load_defaults 5.2
```
を、

```
    config.load_defaults 5.1
```
に書き換える。

```
R0229-MacBook-Pro:hello_app r0229$ rails s
=> Booting Puma
=> Rails 5.1.6 application starting in development 
=> Run `rails server -h` for more startup options
Exiting
/Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `active_storage' for #<Rails::Application::Configuration:0x00007fa01592f0d8> (NoMethodError)
	from /Users/r0229/dev/hello_app/config/environments/development.rb:31:in `block in <main>'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/railtie.rb:211:in `instance_eval'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/railtie.rb:211:in `configure'
	from /Users/r0229/dev/hello_app/config/environments/development.rb:1:in `<main>'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/engine.rb:600:in `block (2 levels) in <class:Engine>'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/engine.rb:599:in `each'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/engine.rb:599:in `block in <class:Engine>'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/initializable.rb:48:in `each'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/initializable.rb:48:in `tsort_each_child'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:347:in `each'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:347:in `call'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!'
	from /Users/r0229/dev/hello_app/config/environment.rb:5:in `<main>'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
	from config.ru:3:in `block in <main>'
	from /Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `instance_eval'
	from /Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `initialize'
	from config.ru:in `new'
	from config.ru:in `<main>'
	from /Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in `eval'
	from /Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in `new_from_string'
	from /Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/builder.rb:40:in `parse_file'
	from /Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/server.rb:319:in `build_app_and_options_from_config'
	from /Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/server.rb:219:in `app'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:24:in `app'
	from /Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/server.rb:354:in `wrapped_app'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:80:in `log_to_stdout'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:42:in `start'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:135:in `block in perform'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `tap'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `perform'
	from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
	from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
	from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke'
	from /Library/Ruby/Gems/2.3.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<main>'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Library/Ruby/Gems/2.3.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
	from /Library/Ruby/Gems/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
	from /Users/r0229/dev/hello_app/bin/rails:9:in `<top (required)>'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
	from /Library/Ruby/Gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /Users/r0229/dev/hello_app/bin/spring:15:in `<top (required)>'
	from bin/rails:3:in `load'
	from bin/rails:3:in `<main>'
```
またまたエラーが。。。

この後も似たようなエラーがずっと出てきて拉致があかないなと思い、よくよく考えると、Rails5.2.2が使われているのが原因ではないかと思い当たる。(5.1.6で指定してダウンロードしたはずだが)

自分のPCには、Rails5.2.2も確かに入っていたので、下記の手順に従ってアンインストールをした。

https://qiita.com/Hassan/items/eef26c870eb26a0c68e0

それから、

`$　rails -v`

をすると、5.1.6と表記された。

再度、 チュートリアルを同じ手順でやり始めて、

`$ rails s`

をやると、ようやくサーバーが立ち上がりました。。。。。