$ rails new ○○_app
$ rails s
とやったら、、
あれ?
立ち上がらない、、
ということになりました。
色々調べると、gemが壊れているのではないかと言うところに辿り着きました。
ですのでその解決した方法を記述しておきたいと思います。
環境
Rails version: 5.2.4.4
Ruby version: 2.6.6 (x86_64-darwin19)
VSCode
rails s をしたらこんなこと言われた
/Users/REITA/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activemodel-5.2.4.4/lib/active_model/validations/clusivity.rb:8: warning: already initialized constant ActiveModel::Validations::Clusivity::ERROR_MESSAGE
/Users/reita/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activemodel-5.2.4.4/lib/active_model/validations/clusivity.rb:8: warning: previous definition of ERROR_MESSAGE was here
Started GET "/" for ::1 at 2021-01-25 16:21:16 +0900
Processing by Rails::WelcomeController#index as HTML
Completed 406 Not Acceptable in 27ms (ActiveRecord: 0.0ms)
ActionController::UnknownFormat (Rails::WelcomeController#index is missing a template for this request format and variant.
request.formats: ["text/html"]
request.variant: []
NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.):
actionpack (5.2.4.4) lib/action_controller/metal/implicit_render.rb:55:in `default_render'
actionpack (5.2.4.4) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (5.2.4.4) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (5.2.4.4) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.4.4) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.4.4) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.4.4) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.4.4) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.4.4) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.4.4) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.4.4) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.4.4) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.4.4) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.4.4) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.4.4) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.4.4) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.4.4) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.4.4) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.4.4) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.4.4) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.4.4) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.4.4) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.4.4) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.4.4) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.4.4) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.4.4) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.4.4) lib/action_dispatch/routing/route_set.rb:840:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (5.2.4.4) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.4.4) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.4.4) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.4.4) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.4.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.4.4) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.4.4) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.4.4) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.4.4) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.4.4) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.4.4) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.4.4) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
railties (5.2.4.4) lib/rails/engine.rb:524:in `call'
puma (3.12.6) lib/puma/configuration.rb:227:in `call'
puma (3.12.6) lib/puma/server.rb:706:in `handle_request'
puma (3.12.6) lib/puma/server.rb:476:in `process_client'
puma (3.12.6) lib/puma/server.rb:334:in `block in run'
puma (3.12.6) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
Started GET "/" for ::1 at 2021-01-25 16:22:22 +0900
Processing by Rails::WelcomeController#index as HTML
Completed 406 Not Acceptable in 24ms (ActiveRecord: 0.0ms)
なっが。笑
ようはcontroller
はあるけど、view
がない
と言われているらしいです。
なので
$ bundle install --redownload
をしてrails s
をしてみたがそれでもダメでした。
結果どうしたのかというと
$ bundle install --path vendor/bundle
$ bundle exec rails s
出来ました!!
最後に
bundle install --path vender/bundle
こちらのオプションをつけると、アプリのフォルダにvendor
というフォルダが作られて
その中にgemがインストールされます。
今まではパソコン内にインストールされていたgemを参照していたのですが
bundle exec
をつけることでvendor内のgemを参照するようになります。
つまり、綺麗にインストールされたgemを使える
という感じですね。
面倒ですが、今後もrailsコマンドを使うときはbundle execをつける必要があります。