前提・実現したいこと
ローカルからCapistranoを使用した自動デプロイを実行し正常にデプロイできるようにしたいです。
今回参考にして作業を進めた記事はこちら↓
(Capistrano編)世界一丁寧なAWS解説。EC2を利用して、RailsアプリをAWSにあげるまで
発生している問題・エラーメッセージ
bundle exec cap production deployでの自動デプロイ実行時の
deploy:assets:precompileの処理中にエラーが発生してデプロイが失敗してしまいます。
00:42 deploy:assets:precompile 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile #<Thread:0x00007ff233b2f098@/Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true): Traceback (most recent call last): 13: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' 12: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `run' 11: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `instance_exec' 10: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/capistrano-rails-1.4.0/lib/capistrano/tasks/assets.rake:67:in `block (4 levels) in <top (required)>' 9: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:92:in `within' 8: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/capistrano-rails-1.4.0/lib/capistrano/tasks/assets.rake:68:in `block (5 levels) in <top (required)>' 7: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:100:in `with' 6: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/capistrano-rails-1.4.0/lib/capistrano/tasks/assets.rake:69:in `block (6 levels) in <top (required)>' 5: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:80:in `execute' 4: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute' 3: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `tap' 2: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute' 1: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/netssh.rb:170:in `execute_command' /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/command.rb:97:in `exit_status=': rake exit status: 1 (SSHKit::Command::Failed) rake stdout: Nothing written rake stderr: Nothing written 1: from /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' /Users/kazu/friends1/vendor/bundle/ruby/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as kazuki@18.180.36.193: rake exit status: 1 (SSHKit::Runner::ExecuteError) rake stdout: Nothing written rake stderr: Nothing written (Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as kazuki@18.180.36.193: rake exit status: 1 rake stdout: Nothing written rake stderr: Nothing written Caused by: SSHKit::Command::Failed: rake exit status: 1 rake stdout: Nothing written rake stderr: Nothing written Tasks: TOP => deploy:assets:precompile (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as kazuki@18.180.36.193: rake exit status: 1 rake stdout: Nothing written rake stderr: Nothing written ** DEPLOY FAILED ** Refer to log/capistrano.log for details. Here are the last 20 lines: DEBUG [9de458f3] * spring (2.1.0) DEBUG [9de458f3] * spring-commands-rspec (1.0.4) DEBUG [9de458f3] * spring-watcher-listen (2.0.1) DEBUG [9de458f3] * tzinfo-data (1.2019.3) DEBUG [9de458f3] * unicorn (5.5.4) DEBUG [9de458f3] * web-console (4.0.1) DEBUG [9de458f3] * webdrivers (4.2.0) DEBUG [9de458f3] Install missing gems with `bundle install` DEBUG [9de458f3] Finished in 1.543 seconds with exit status 1 (failed). INFO [2bcfe84e] Running $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/friends/shared/bundle --jobs 4 --without development test --deployment --quiet as kazuki@18.180.36.193 DEBUG [2bcfe84e] Command: cd /var/www/friends/releases/20200326124814 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.6.5" ; $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/friends/shared/bundle --jobs 4 --without development test --deployment --quiet ) DEBUG [2bcfe84e] [DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag DEBUG [2bcfe84e] [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path '/var/www/friends/shared/bundle'`, and stop using this flag DEBUG [2bcfe84e] [DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'development test'`, and stop using this flag INFO [2bcfe84e] Finished in 8.179 seconds with exit status 0 (successful). DEBUG [c5d0c262] Running if test ! -d /var/www/friends/releases/20200326124814; then echo "Directory does not exist '/var/www/friends/releases/20200326124814'" 1>&2; false; fi as kazuki@18.180.36.193 DEBUG [c5d0c262] Command: if test ! -d /var/www/friends/releases/20200326124814; then echo "Directory does not exist '/var/www/friends/releases/20200326124814'" 1>&2; false; fi DEBUG [c5d0c262] Finished in 0.306 seconds with exit status 0 (successful). INFO [434ac5f0] Running $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile as kazuki@18.180.36.193 DEBUG [434ac5f0] Command: cd /var/www/friends/releases/20200326124814 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.6.5" RAILS_ENV="production" RAILS_GROUPS="" ; $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
capstranoを使用するのが初めてで何がダメなのかさっぱり分からない状況です…
補足情報(FW/ツールのバージョンなど)
rails6
mysql2(ローカル環境)
AWS EC2
アドバイスしていただけたら幸いです。
よろしくお願いいたします。
あなたの回答
tips
プレビュー