4
2

More than 3 years have passed since last update.

unicorn起動時の凡ミス(bundler: failed to load command: unicorn_rails)

Posted at

はじめに

AWSでポートフォリオをデプロイする事ができました。

デプロイするのに様々なエラーがあったので復習のために投稿します。

今回はunicorn起動時に起きたエラーです。

bundler: failed to load command: unicorn_rails

EC2内
[ec2-user@ip-10-0-0-53 <リポジトリ名>]$ bundle exec unicorn_rails -c /var/www/rails/アプリ名/config/unicorn.conf.rb -D -E production

このようにEC2内で起動コマンドをしました。

EC2内
bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails)

rubygems_integration.rb:364:in `block in replace_bin_path': can't find executable unicorn_rails for gem unicorn. unicorn is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)

1つづつエラーを見ていきます。

bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.5/bin/unicorn_rails)

コマンドの読み込みに失敗しました:unicorn_rails
これは単純に何かのエラーで読み込めませんでしたよと言われています。
もう1つのエラーが原因が記述されています。

rubygems_integration.rb:364:in `block in replace_bin_path': can't find executable unicorn_rails for gem unicorn. unicorn is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)

Image from Gyazo

和訳サイトで確認すると強気な和訳が返されました(笑)

単純にgemをインストールしてないだけでした。

確認作業

gemのディレクトリーを確認します。

EC2内
[ec2-user@ip-10-0-0-53 <リポジトリ名>]$ vi Gemfile

テキストエディター開くコマンドで確認することができます。

Gemfile

#省略

gem 'pry-rails'

gem 'kaminari'

gem 'ransack'

gem 'gretel'

1番下には記述されていませんでした。

ここで記述していきます。

iコマンドを押すと記述できるようになります。

Gemfile
group :production, :staging do
    gem 'unicorn'
end

記述した後:wqで編集完了。

EC2内
[ec2-user@ip-10-0-0-53 <リポジトリ名>]$ gem install bundler
[ec2-user@ip-10-0-0-53 <リポジトリ名>]$ bundle install

すでにunicornの設定はできているので、最初の起動コマンドを押して起動します。

最後に

慎重にやっていたらミスらないと思うので確実にこなしていきたいと思います。

4
2
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
4
2