LoginSignup
0
0

More than 1 year has passed since last update.

【Git】【Ruby】 Gemfile,Gemfile.lock変更後、git push後にエラー

Last updated at Posted at 2021-11-26

1. 概要

Ruby on rails アプリ(開発環境の更新が本番環境に反映されるようGitHub Actions設定済み)
にて、Gemfileに新機能を色々追加したり試したりした後
git push後にエラー発生・・時に自分が解決したやり方を記載

2.エラー内容/対処

Githubのactionsから最新ワークフローを確認した際に
Deploy時エラーが発生していた

git.png

以下がエラー内容詳細

Run echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
Warning: Permanently added '***' (ECDSA) to the list of known hosts.
From github.com:syokaturyou/sangoku
 * branch            main       -> FETCH_HEAD
   b1b89e5..4a8562f  main       -> origin/main
error: Your local changes to the following files would be overwritten by merge:
    Gemfile.lock
Please commit your changes or stash them before you merge.
Aborting
Error: Process completed with exit code 128.

本番環境のGemfile.lock とpushした内容と食い違いがあるために起こったと考えられるため
本番環境(自分の場合aws EC2インスタンスを使用)のGemfile.lockを一旦削除
※Gemfileが確認できるディレクトリに移動し以下を実行

[ec2-user@ip-〇-〇-〇-〇 アプリ名] rm Gemfile.lock

→Gemfile.lock削除後には本番環境でgit pull origin main 実行

これで直ったと思い再度開発環境の更新内容をgit pushするも
今度はDeploy時エラーとして以下がgithubのactions上で発生していた。

Run echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
Warning: Permanently added '***' (ECDSA) to the list of known hosts.
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.
Error: Process completed with exit code 128.

マージが完了しておらず、MERGE_HEADが存在しているために発生しているエラーと考えられる。
本番環境でgit pull した時には以下が発生していた。

[ec2-user@ip-〇-〇-〇-〇 アプリ名]$ git pull origin main
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.

「hint: Please, commit your changes before merging.」の記載に従って
本番環境下で空コミット

[ec2-user@ip-〇-〇-〇-〇 アプリ名]git commit --allow-empty -m "commitmessage"

空コミット後にgit pullを実行するとエラーは発生せず

[ec2-user@ip-〇-〇-〇-〇 アプリ名]$ git pull origin main

この状態で開発環境で修正内容をgit push すると本番環境でも正常更新された

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