LoginSignup
4
1

More than 5 years have passed since last update.

GemfileのgithubショートハンドでGemfile.lockのプロトコルが強制的にgitになる問題

Posted at

tl;dr

関わっているプロジェクト(Ruby on Rails)で、bundle installを実行したところ、Gemfile.lockに以下のような差分が出てきてコミットできない状況に陥ったので、解決策をメモ。

-  remote: https://github.com/hogehoge/hoge.git
+  remote: git://github.com/hogehoge/hoge.git

参考

以下のブログを参考にさせてもらいました。
bundler 1.13.0でGemfileに:github ショートハンドを使用するとwarningが出る

概要

Gemfileに以下のような記載がある場合、
github:をショートハンドと呼ぶんだそうです)

Gemfile
gem 'hoge', github: 'hogehoge/hoge'

bundle installを実行すると、Gemfile.lockにはこんな感じに記載される。

Gemfile.lock
remote: git://github.com/hogehoge/hoge.git

プロトコルがhttpsではなくgitに置き換わってしまうことで差分が発生するので、コミットに含められない事態に。
(他の人がどうやってhttpsで運用してるのか知らなかった)

解決方法

gitの設定をちょっとだけ直してあげます。

$ bundle config github.https true

上記コマンドを実行してあげれば、ショートハンドを使った場合も、httpsでアクセスしてくれるようになるので、Gemfile.lockも変な差分は出ないようになります。

おまけ

参考サイトの方にも書かれていますが、githubショートハンドを使った状態でbundle installを実行すると、以下のような警告が出ます。

The git source `git://github.com/hogehoge/hoge.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.

「gitプロトコルは暗号化されないので、セキュアじゃないよ。https使ったほうがいいんじゃね?」ってことです。

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