Rails6 デプロイ エラーのメモ

## 急にデプロイできなくなった場合
こういうエラーs

```
warning "webpack-dev-server > webpack-dev-middleware@3.7.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning "admin-lte > bootstrap-switch@3.3.4" has incorrect peer dependency "bootstrap@^3.1.1".
warning " > tempusdominus-bootstrap-4@5.39.0" has unmet peer dependency "moment@^2.29.0".
warning " > tempusdominus-bootstrap-4@5.39.0" has unmet peer dependency "moment-timezone@^0.5.31".
warning " > tempusdominus-bootstrap-4@5.39.0" has unmet peer dependency "tempusdominus-core@5.19.0".
warning " > bootstrap4-datetimepicker@5.2.3" has incorrect peer dependency "bootstrap@4.0.0-alpha.6".
warning " > bootstrap4-datetimepicker@5.2.3" has unmet peer dependency "moment@^2.10".
warning " > bootstrap4-datetimepicker@5.2.3" has unmet peer dependency "moment-timezone@^0.4.0 || ^0.5.0".
warning " > webpack-dev-server@3.11.2" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.7.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
	1: from /Users/XXX/path_to_app/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/XXX/path_to_app/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as deploy_user@153.126.207.212: rake exit status: 1 (SSHKit::Runner::ExecuteError)
rake stdout: yarn install v1.22.5
```

```

[webpack-cli] Failed to load '/var/www/app/releases/20210428091806/config/webpack/production.js' config
[webpack-cli] TypeError: Cannot read property 'plugins' of undefined
    at Object.<anonymous> (/var/www/app/releases/20210428091806/config/webpack/environment.js:4:13)
    at Module._compile (/var/www/app/releases/20210428091806/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/var/www/app/releases/20210428091806/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/var/www/app/releases/20210428091806/config/webpack/production.js:3:21)
    at Module._compile  (/var/www/app/releases/20210428091806/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
```

```

Caused by:
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: /var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy_user@133.125.60.37: rake exit status: 1
rake stdout: Nothing written
rake stderr: /var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/var/www/app/shared/bundle/ruby/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead

```

```

bundle stdout: Nothing written
bundle stderr: master failed to start, check stderr log for details
	1: from /Users/XXX/path_to_app/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/XXX/path_to_app/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as deploy_user@xx.xx.xx.xx: bundle exit status: 1 (SSHKit::Runner::ExecuteError)
bundle stdout: Nothing written
bundle stderr: master failed to start, check stderr log for details
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy_user@xx.xx.xx.xx.: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: master failed to start, check stderr log for details
```

```
Caused by:
SSHKit::Command::Failed: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: master failed to start, check stderr log for details
/Users/XXX/path_to_app/lib/capistrano/tasks/unicorn.rake:8:in `block in start_unicorn'
/Users/XXX/path_to_app/lib/capistrano/tasks/unicorn.rake:7:in `start_unicorn'
/Users/XXX/path_to_app/lib/capistrano/tasks/unicorn.rake:53:in `block (3 levels) in <top (required)>'
Tasks: TOP => unicorn:force_restart
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy_user@153.126.207.212: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: master failed to start, check stderr log for details

```

## webpacker 再設定

```
% bin/rails webpacker:install
   identical  config/webpacker.yml
Copying webpack core config
       exist  config/webpack
   identical  config/webpack/development.js
    conflict  config/webpack/environment.js
Overwrite /Users/XXX/path_to_app/config/webpack/environment.js? (enter "h" for help) [Ynaqdhm] 
       force  config/webpack/environment.js
   identical  config/webpack/production.js
   identical  config/webpack/test.js
Copying postcss.config.js to app root directory
   identical  postcss.config.js
Copying babel.config.js to app root directory
   identical  babel.config.js
Copying .browserslistrc to app root directory
   identical  .browserslistrc
The JavaScript app source directory already exists
       apply  /Users/XXX/path_to_app/vendor/bundle/ruby/2.7.0/gems/webpacker-4.3.0/lib/install/binstubs.rb
  Copying binstubs
       exist    bin
   identical    bin/webpack
   identical    bin/webpack-dev-server
```

各ファイルが書き変わってしまうので注意。
確認

- package.json

```
   "dependencies": {
     "@fortawesome/fontawesome-free": "^5.15.2",
     "@rails/ujs": "^6.0.0",
-    "@rails/webpacker": "^6.0.0-beta.7",
+    "@rails/webpacker": "4.3.0",
     "admin-lte": "3.0.5",
     "bootstrap": "^4.5.3",
     "bootstrap4-datetimepicker": "^5.2.3",



   },
   "version": "0.1.0",
   "devDependencies": {
-    "webpack-dev-server": "^3.11.0"
+    "webpack-dev-server": "^3.11.2"
   }
 }

```