LoginSignup
1
0

More than 1 year has passed since last update.

EC2上にrailsアプリをデプロイするまで~puma起動で躓いた所を整理

Last updated at Posted at 2022-08-28

アプリケーションのpumaの起動で起きたエラーとその解決策を記録。

もろもろの設定を終えた後に

bundle exec pumactl start

で起動しようとすると、

! Unable to load application: Aws::Sigv4::Errors::MissingCredentialsError: missing credentials, provide credentials with one of the following options:

  • :access_key_id and :secret_access_key
  • :credentials
  • :credentials_provider
    missing credentials, provide credentials with one of the following options:
  • :access_key_id and :secret_access_key
  • :credentials
  • :credentials_provider

という謎エラー。数日前に苦労して起動させたときはこんなもん表示されずに起動したから泣きそうになった。

何やら認証情報がどーたらこーたららしいのだが、すでに心折れたので質問して待機中。

何故か1日経って起動したら何事もなく起動できたのでたぶん神がお許しになった。

ようやくブラウザのアドレスバーにEC2のIPアドレスを叩いて、サンプルアプリを起動…!

ActiveRecord::NoDatabaseError
Unknown database 'アプリの名前'
Extracted source (around line #43):
41
42
43
44
45
46

    rescue Mysql2::Error => error
      if error.error_number == ConnectionAdapters::Mysql2Adapter::ER_BAD_DB_ERROR
        raise ActiveRecord::NoDatabaseError
      else
        raise ActiveRecord::ConnectionNotEstablished, error.message
      end

と思ったらこのエラー

database.ymlのdatabaseの名前が違ったみたいで、訂正してもう一度起動。

502 Bad Gateway
nginx/1.20.0

次は君か。まぁこれはpumaを起動し忘れてただけ。pumaを再度起動すれば

ActiveRecord::PendingMigrationError
Migrations are pending. To resolve this issue, run:
bin/rails db:migrate RAILS_ENV=development
You have 2 pending migrations:
20210129231905_create_fruits.rb
20211003014450_create_active_storage_tables.active_storage.rb

うむ、エラーである。

エラーメッセージの中のbin/rails db:migrate RAILS_ENV=developmentをそのまま叩けば解決した。

ところが、

Webpacker::Manifest::MissingEntryError in Fruits#index
Showing /var/www/lecture05/app/views/layouts/application.html.slim where line #9 raised:

Webpacker can't find application.js in /var/www/lecture05/public/packs/manifest.json. Possible causes:

  1. You want to set webpacker.yml value of compile to true for your environment
    unless you are using the webpack -w or the webpack-dev-server.

  2. webpack has not yet re-run to reflect updates.

  3. You have misconfigured Webpacker's config/webpacker.yml file.

  4. Your webpack configuration is not creating a manifest.
    Your manifest contains:
    {
    }
    Extracted source (around line #9):
    7
    8
    9
    10
    11
    12

    meta name="description" content="#{content_for?(:description) ? yield(:description) : 'Sortable Table Sandbox'}"
    == stylesheet_pack_tag "application", :media => 'all'
    == javascript_pack_tag 'application'
    == csrf_meta_tags
    body
    header

ほいまたエラーですわ。webpackerがコンパイルされてないらしい。なんのこっちゃ。

この記事通りにコマンドを叩けばOK。

そしてやっとのことで、ブラウザにデプロイ完了…!!!

一ヶ月以上かかりましたわ…(実質勉強したのは半分以下)

1
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
1
0