2
0

More than 1 year has passed since last update.

CapistranoでAWS EC2にデプロイする際に、`bundle lock --add-platform x86_64-linux` and try again.で詰まった

Posted at

はじめに

学習用のメモとして投稿します。
Capistranoを使用して、Railsで作成したアプリをAWS EC2にデプロイをする機会がありました。
その際に遭遇したエラー`bundle lock --add-platform x86_64-linux` and try again.とその解決策について書いていきます。

Capistranoでデプロイ

色々と設定して、いざデプロイということで、次のコマンドを実行します。

bundle exec cap production deploy

・・・失敗しました。。

エラーを見ると、次のような記載があります。

# 略
Your bundle only supports platforms ["aarch64-linux"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with
`bundle lock --add-platform x86_64-linux` and try again.
# 略

親切にもbundle lock --add-platform x86_64-linuxを実行してから、再度トライするように教えてくれています。
指示通りに、ターミナルで次のコマンドを実行します。

bundle lock --add-platform x86_64-linux

このコマンドにより、Gemfileにプラットフォームが追加されます。

Gemfile
# 略
PLATFORMS
  aarch64-linux
  x86_64-linux # 追加
end
# 略

準備は整ったので、次のコマンドを再度実行します。

bundle exec cap production deploy

・・・失敗しました。。

エラーを見ると、さっきと同じ内容が。。

# 略
Your bundle only supports platforms ["aarch64-linux"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with
`bundle lock --add-platform x86_64-linux` and try again.
# 略

原因

ローカルでの変更を、リモートリポジトリにプッシュしていないためでした。
bundle exec cap production deployコマンドでは、設定したリモートリポジトリのコードを、設定したデプロイ先にデプロイしてくれますが、このコマンドが、リモートリポジトリへのプッシュの実行まで含んでいるわけではありません。変更をリモートリポジトリにプッシュして、再度トライします。

git push origin main
bundle exec cap production deploy

これでようやくデプロイできました。
よく理解しないままコマンドを打つのは良くないと改めて痛感しました。

参考にした記事

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