0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SSHKit::Runner::ExecuteError【AWS,Capistrano】

Posted at

はじめに

Capistranoを使用して、AWSに自動デプロイを行なった際に下記のエラーが出たので、備忘録として投稿します。

エラー内容

$  bundle exec cap production deploy

で自動デプロイを始めると

SHKit::Runner::ExecuteError: Exception while executing as ec2-user@Elastic IP: rake exit status: 1
rake stdout: Nothing written
rake stderr: bundler: failed to load command: rake (/var/www/app/shared/bundle/ruby/2.6.0/bin/rake)
Gem::Exception: can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
  /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:374:in `block in replace_bin_path'
  /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:402:in `block in replace_bin_path'
  /var/www/app/shared/bundle/ruby/2.6.0/bin/rake:23:in `<top (required)>'


Caused by:
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: bundler: failed to load command: rake (/var/www/app/shared/bundle/ruby/2.6.0/bin/rake)
Gem::Exception: can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
  /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:374:in `block in replace_bin_path'
  /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:402:in `block in replace_bin_path'
  /var/www/app/shared/bundle/ruby/2.6.0/bin/rake:23:in `<top (required)>'

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as ec2-user@Elastic IP: rake exit status: 1
rake stdout: Nothing written
rake stderr: bundler: failed to load command: rake (/var/www/app/shared/bundle/ruby/2.6.0/bin/rake)
Gem::Exception: can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
  /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:374:in `block in replace_bin_path'
  /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:402:in `block in replace_bin_path'
  /var/www/app/shared/bundle/ruby/2.6.0/bin/rake:23:in `<top (required)>'


** DEPLOY FAILED

というエラーが出てしまい、GEMのバージョンが古いのかと思い、ローカル環境で

gem update --system
bundle update rake

などを試したのですが解決せず。

その後EC2の環境がおかしいのではと考え、

EC2のbundlerのバージョンをローカルと揃えてから
再度試したところ解決。

原因はローカルでバージョンを変更したのに、EC2は変更していなかったことでした。

原因を決めつけず、色々探ることが大切だと学べました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?