LoginSignup
2
0

More than 1 year has passed since last update.

Fly.ioにRailsアプリをデプロイした時に色々なエラーが出たので解決した

Last updated at Posted at 2022-11-29

環境

  • OS
    • エディション Windows 10 Home
    • バージョン 21H1
    • OS ビルド 19043.2130
  • ruby --version
    • ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]
  • rails --version
    • Rails 6.1.7
  • flyctl version
    • flyctl.exe v0.0.435 windows/amd64 Commit: c5149629 BuildDate: 2022-11-22T16:41:44Z

背景

 HerokuのPostgres無料プラン終了に伴い、HerokuにデプロイしていたRailsアプリをFly.ioにデプロイし直しました。
 基本的には以下の記事を参考にデプロイしましたが、記事内に出てこないエラーに遭遇したので、どのように解決したかを書いていきます。
Fly.ioでデプロイする手順(Window) - Qiita

発生したエラー

1.「flyctl launch」に失敗する

  • PowerShellで「flyctl launch」を実行したら、以下のようなエラーが出て失敗しました
PS D:\Programming\RubyOnRails\sample_app2> flyctl launch
Creating app in D:\Programming\RubyOnRails\sample_app2
Scanning source code
Detected a Rails app
Error name argument or flag must be specified when not running interactively

解決策

2.「flyctl launch」を実行した際にFailed attaching <アプリ名> to the Postgres clusterというエラーメッセージが出る

500: ERROR: syntax error at or near "4" (SQLSTATE 42601) flyio

解決策

3.「fly deploy」を実行した際にERROR [internal] load metadata for quay.io/evl.ms/fullstaq-ruby:2.7.2-jemalloc-bullseye-slimというエラーが出る

  • 上の通りです
  • Gemfileの4行目のruby '2.7.2'をコメントアウトしても、解決しませんでした

解決策

Dockerfile
ARG RUBY_VERSION=2.7.2
ARG VARIANT=jemalloc-buster-slim # この行を「jemalloc-bullseye-slim」から変更しました
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-${VARIANT} as base

4.「fly deploy」を実行した際にERROR [gems 2/2] RUN bundle install && rm -rf vendor/bundle/ruby/*/cacheというエラーが出る

  • 上の通りです

解決策

  • 単純に「bundle install」に失敗しているので、その原因を取り除けばよいです
  • 「bundle install」の実行結果がコマンドプロンプト上に表示されていると思いますので、それを確認しましょう
  • 自分の場合は、以下の2つの操作を行いました
    1. そもそも最後に「bundle install」を実行したのがかなり前でGemfile.lockの内容が古くなっており、一部gemについて既に公開されていないバージョンをインストールしようとしていたので、Gemfile.lockを削除して「bundle install」を実行し直しました
    2. 上の記事の補足を参考に、Gemfile内のgem 'sqlite3'のコメントアウトを外し、かつバージョン指定を削除しました

以上

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