Rubyでwebサーバーを立ち上げたらうまく立ち上がらず。
$ rails server
=> Booting Puma
=> Rails 6.0.0 application starting in development
=> Run `rails server --help` for more startup options
RAILS_ENV=development environment is not defined in config/webpacker.yml, falling back to production environment
Exiting
どうやらwebpacker.ymlがないのが原因っぽい。
インストールしてみる
$ rails webpacker:install
そしたらこんなのが出てきた
rails aborted!
Don't know how to build task 'webpacker:install
' (See the list of available tasks with `rails --tasks`)
Did you mean? webpacker:install
webpacker:install:vue
webpacker:install:erb
webpacker:install:elm
webpacker:binstubs
/Library/Ruby/Gems/2.6.0/gems/railties-6.0.0/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/Library/Ruby/Gems/2.6.0/gems/railties-6.0.0/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/Library/Ruby/Gems/2.6.0/gems/railties-6.0.0/lib/rails/command.rb:48:in `invoke'
/Library/Ruby/Gems/2.6.0/gems/railties-6.0.0/lib/rails/commands.rb:18:in `<main>'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
/Users/tatsuya/Desktop/ruby/blog/bin/rails:9:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/tatsuya/Desktop/ruby/blog/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)
うまくインストールされないので直接ぶちこむ作戦に変更。
ここのソースコードをそのままconfigにファイルを作って貼り付ける
$rails server
=> Booting Puma
=> Rails 6.0.0 application starting in development
=> Run `rails server --help` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/" for ::1 at 2019-10-25 15:26:57 +0900
(2.0ms) SELECT sqlite_version(*)
Processing by Rails::WelcomeController#index as HTML
Rendering /Library/Ruby/Gems/2.6.0/gems/railties-6.0.0/lib/rails/templates/rails/welcome/index.html.erb
Rendered /Library/Ruby/Gems/2.6.0/gems/railties-6.0.0/lib/rails/templates/rails/welcome/index.html.erb (Duration: 7.8ms | Allocations: 480)
Completed 200 OK in 24ms (Views: 13.1ms | ActiveRecord: 0.0ms | Allocations: 2737)
立ち上がったぜ!
でも、原因がわからない
立ち上がりはしたけどなんでうまくwebpackerがインストールされないか分からずです。
ご存知の方おられれば教えていただきたいです。