質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

rbenv

rbenvは、Rubyバージョン管理ツール。プロジェクトごとでRubyバージョンを切り替えることが可能です。RVMよりもシンプルで、少ない機能で動作します。本体にはRubyのビルド機能は備わっておらず、ruby-buildというツールを用いる必要があります。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

Q&A

0回答

753閲覧

capistrano3で`bundle exec cap production deploy`を完了できません

aiuhaeufh08

総合スコア0

unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

rbenv

rbenvは、Rubyバージョン管理ツール。プロジェクトごとでRubyバージョンを切り替えることが可能です。RVMよりもシンプルで、少ない機能で動作します。本体にはRubyのビルド機能は備わっておらず、ruby-buildというツールを用いる必要があります。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

0グッド

0クリップ

投稿2020/06/24 00:24

編集2020/06/24 13:02

前提・実現したいこと

capistrano3でbundle exec cap production deployを完了できません。

現象としてはこちらの方と同じだと思います。
https://teratail.com/questions/232214

原因解明のために必要な情報があれば追記します。
よろしくお願いします。

発生している問題・エラーメッセージ

00:18 deploy:assets:precompile 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile #<Thread:0x00007ff9afa6f828 /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.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/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' 12: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `run' 11: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `instance_exec' 10: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capistrano-rails-1.5.0/lib/capistrano/tasks/assets.rake:67:in `block (4 levels) in <top (required)>' 9: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:92:in `within' 8: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capistrano-rails-1.5.0/lib/capistrano/tasks/assets.rake:68:in `block (5 levels) in <top (required)>' 7: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:100:in `with' 6: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capistrano-rails-1.5.0/lib/capistrano/tasks/assets.rake:69:in `block (6 levels) in <top (required)>' 5: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:80:in `execute' 4: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute' 3: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `tap' 2: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute' 1: from /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/netssh.rb:170:in `execute_command' /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.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/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' /Users/aiuhaeufh08/.anyenv/envs/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as aiuhaeufh08@××.×××.×××.×××: 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 aiuhaeufh08@××.×××.×××.×××: 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 aiuhaeufh08@××.×××.×××.×××: 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 [3cae4fbf] * listen (3.2.1) DEBUG [3cae4fbf] * rubyzip (2.3.0) DEBUG [3cae4fbf] * selenium-webdriver (3.142.7) DEBUG [3cae4fbf] * spring (2.1.0) DEBUG [3cae4fbf] * spring-watcher-listen (2.0.1) DEBUG [3cae4fbf] * web-console (4.0.3) DEBUG [3cae4fbf] * webdrivers (4.4.1) DEBUG [3cae4fbf] Install missing gems with `bundle install` DEBUG [3cae4fbf] Finished in 0.532 seconds with exit status 1 (failed). INFO [2323cc29] Running $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/rails/aiuhaeufh08/shared/bundle --jobs 4 --without development test --deployment --quiet as aiuhaeufh08@××.×××.×××.××× DEBUG [2323cc29] Command: cd /var/www/rails/aiuhaeufh08/releases/20200623234746 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.7.0" ; $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/rails/aiuhaeufh08/shared/bundle --jobs 4 --without development test --deployment --quiet ) DEBUG [2323cc29] [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 [2323cc29] [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/rails/aiuhaeufh08/shared/bundle'`, and stop using this flag DEBUG [2323cc29] [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 [2323cc29] Finished in 0.708 seconds with exit status 0 (successful). DEBUG [6639e213] Running if test ! -d /var/www/rails/aiuhaeufh08/releases/20200623234746; then echo "Directory does not exist '/var/www/rails/aiuhaeufh08/releases/20200623234746'" 1>&2; false; fi as aiuhaeufh08@××.×××.×××.××× DEBUG [6639e213] Command: if test ! -d /var/www/rails/aiuhaeufh08/releases/20200623234746; then echo "Directory does not exist '/var/www/rails/aiuhaeufh08/releases/20200623234746'" 1>&2; false; fi DEBUG [6639e213] Finished in 0.242 seconds with exit status 0 (successful). INFO [d6bd8233] Running $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile as aiuhaeufh08@××.×××.×××.××× DEBUG [d6bd8233] Command: cd /var/www/rails/aiuhaeufh08/releases/20200623234746 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.7.0" RAILS_ENV="production" RAILS_GROUPS="" ; $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )

試したこと

①まず下記の記事を参考にcapistranoを導入しました。
https://qiita.com/naoki_mochizuki/items/657aca7531b8948d267b

②上記エラーの前に暗号化キーがないと言われたのでシンボリックリンクを下記の通りにしました。
サーバー側にもコピー済みです。

# set :linked_files, fetch(:linked_files, []).push('config/settings.yml') set :linked_files, fetch(:linked_files, []).push("config/master.key")

③サーバー側にcurrentファイルがないと怒られたので手動で作りました。

ファイル

■config/deploy/production.rb

role :web, %w{aiuhaeufh08@××.×××.×××.×××} role :app, %w{aiuhaeufh08@××.×××.×××.×××} role :db, %w{aiuhaeufh08@××.×××.×××.×××} server "××.×××.×××.×××", user: "aiuhaeufh08", roles: %w{app db web} set :ssh_options, { keys: %w(~/.ssh/key_rsa), forward_agent: false, auth_methods: %w(publickey) }

■config/environments/production.rb

Rails.application.configure do config.cache_classes = true config.eager_load = true config.consider_all_requests_local = false config.action_controller.perform_caching = true config.require_master_key = true config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? config.assets.compile = false config.active_storage.service = :local config.log_level = :debug config.log_tags = [ :request_id ] config.action_mailer.perform_caching = false config.i18n.fallbacks = true config.active_support.deprecation = :notify config.log_formatter = ::Logger::Formatter.new if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end config.active_record.dump_schema_after_migration = false end

補足情報(FW/ツールのバージョンなど)

Rails 6.0.3.2
Ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
(ローカルはanyenv、サーバーはrbenv)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問