前提・実現したいこと
現在、Railsでアプリケーションを作成しまして、本番環境にはAWS EC2を使用し、
capistranoで自動デプロイができる設定にしようとしています。
インターネット上に公開されている手順などを参考に環境設定を行い、
デプロイを実行したところ、以下のようなエラーが発生し自力での解決が困難なためご質問させていただきました。
発生している問題・エラーメッセージ
コンテナ内でデプロイを実行しましたところ以下のようなエラーが出力されます。
<実行コマンド> bundle exec cap production deploy
root@fbe6b39ff462:/develop# bundle exec cap production deploy 00:00 hg:check 01 hg id https://github.com/app/production_app.git 01 /usr/bin/env: 01 hg 01 : No such file or directory 01 #<Thread:0x0000559fef86dca8@/usr/local/bundle/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true): Traceback (most recent call last): 1: from /usr/local/bundle/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' /usr/local/bundle/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ec2-user@54.xx.xx.xx: hg exit status: 127 (SSHKit::Runner::ExecuteError) hg stdout: Nothing written hg stderr: /usr/bin/env: hg: No such file or directory (Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@54.xx.xx.xx: hg exit status: 127 hg stdout: Nothing written hg stderr: /usr/bin/env: hg: No such file or directory Caused by: SSHKit::Command::Failed: hg exit status: 127 hg stdout: Nothing written hg stderr: /usr/bin/env: hg: No such file or directory Tasks: TOP => deploy:check => hg:check (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as ec2-user@54.xx.xx.xx: hg exit status: 127 hg stdout: Nothing written hg stderr: /usr/bin/env: hg: No such file or directory ** DEPLOY FAILED ** Refer to log/capistrano.log for details. Here are the last 20 lines: DEBUG [10e531c9] Command: [ -d $HOME/.rbenv/versions/2.5.9 ] DEBUG [10e531c9] Finished in 0.210 seconds with exit status 0 (successful). INFO [0f9341e1] Running /usr/bin/env hg id https://github.com/app/production_app.git as ec2-user@54.xx.xx.xx DEBUG [0f9341e1] Command: ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.9" ; /usr/bin/env hg id https://github.com/app/production_app.git ) DEBUG [0f9341e1] /usr/bin/env: DEBUG [0f9341e1] hg DEBUG [0f9341e1] : No such file or directory DEBUG [0f9341e1] INFO --------------------------------------------------------------------------- INFO START 2021-09-23 12:22:59 +0900 cap production deploy INFO --------------------------------------------------------------------------- DEBUG [7d9ac82b] Running [ -d $HOME/.rbenv/versions/2.5.9 ] as ec2-user@54.xx.xx.xx DEBUG [7d9ac82b] Command: [ -d $HOME/.rbenv/versions/2.5.9 ] DEBUG [7d9ac82b] Finished in 0.226 seconds with exit status 0 (successful). INFO [cac46985] Running /usr/bin/env hg id https://github.com/app/production_app.git as ec2-user@54.xx.xx.xx DEBUG [cac46985] Command: ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.9" ; /usr/bin/env hg id https://github.com/app/production_app.git ) DEBUG [cac46985] /usr/bin/env: DEBUG [cac46985] hg DEBUG [cac46985] : No such file or directory DEBUG [cac46985]
<log/capistrano.log> INFO --------------------------------------------------------------------------- INFO START 2021-09-23 12:48:17 +0900 cap production deploy INFO --------------------------------------------------------------------------- DEBUG [3bd968d4] Running [ -d $HOME/.rbenv/versions/2.5.9 ] as ec2-user@54.xx.xx.xx DEBUG [3bd968d4] Command: [ -d $HOME/.rbenv/versions/2.5.9 ] DEBUG [3bd968d4] Finished in 0.232 seconds with exit status 0 (successful). INFO [ed9c17f2] Running /usr/bin/env hg id https://github.com/app/production_app.git as ec2-user@54.xx.xx.xx DEBUG [ed9c17f2] Command: ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.9" ; /usr/bin/env hg id https://github.com/app/production_app.git ) DEBUG [ed9c17f2] /usr/bin/env: DEBUG [ed9c17f2] hg DEBUG [ed9c17f2] : No such file or directory DEBUG [ed9c17f2]
試したこと
元々は以下のようなssh接続ができない旨のエラーが出ていましたので、
ローカルホスト上に配置していた「~/.ssh/xxxxx.pem」をコンテナ内にもコピーし、再度デプロイを実行しました。
cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@54.xx.xx.xx: Authentication failed for user ec2-user@54.xx.xx.xx
その結果が上記のエラーになるのですが、元々発生していたssh接続自体は解消された?と仮定し、
その後、現在画面上に出ているエラーを調査しているような状況です。
なお、エラー文中にある
「/usr/bin/env: hg: No such file or directory」から、存在しないとみなされているファイルが本番環境上に存在するかどうかを確認したところ、
以下の通り存在はしているように見えましたため、他何か原因があるのかと調査しているものの、原因特定に至っていない状況となります。
[ec2-user@ip-172-31-33-117 production_app]$ ls -lht /usr/bin/env -rwxr-xr-x 1 root root 29K Jan 23 2020 /usr/bin/env
こちらのエラーの原因について、どう解消したら良いかなどご助言をいただけますでしょうか。
補足情報(FW/ツールのバージョンなど)
作業中の開発環境、及び本番環境については以下になります。
<開発環境> Rails 5.2.6 Ruby 2.5.9 bundler 1.17.3 Docker 20.10.7 (Debian 10.10) psql 11.12
<本番環境> Amazon Linux release 2 (Karoo) nginx 1.20.0 unicorn 6.0.0 ※ruby, bundler, DBはいずれも開発環境と同様
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。