0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

既存プロジェクトで Gemfile → gems.rb してみる

Last updated at Posted at 2020-12-26

はじめに

Ruby on Rails の既存プロジェクトを Bundler2.x以降で
Gemfile → gems.rbしたので、その手順を書いておきます。

Gemfile -> gems.rb 、Gemfile.lock -> gems.locked する(オプション)

Gemfile、Gemfile.lock、から ファイル名を変更します。

mv Gemfile gems.rb
mv Gemfile.lock gems.locked

このままでは、プロジェクトの bin 下にあるスクリプトの実行に
失敗するので、次の手順を行います。

プロジェクトの bin 下と config 下にあるスクリプトを変更する

config/boot.rb を、
開いて../Gemfile -> ../gems.rb するか、
gems.rbGemfileの両方に対応するように書き換える必要が
あります。

上の変更は、ad hoc かもしれません?が、自分の環境では動作している
ので、問題ないはずです。

Rails6の頃までは、config/boot.rb 以外のファイルも変更する
必要がありましたが、Rails7以降は、config/boot.rb のみ
変更するだけで済むようになっています。

Rails で利用する gem の中にGemfileのみ考慮していて、
gems.rbを考慮していないモノがあるので、注意が必要です。

最後に

移行手順は以上です。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?