是否可以覆盖 gemfile 进行本地开发?
Is it possible to override gemfile for local development?
我们的 git 存储库中目前有一个 Gemfile
。但是,有一个 gem 我只在我的环境中本地使用(我的团队不使用它)。为了使用它,我必须将它添加到我们的 Gemfile
,但每次我检查到我们的 master/dev 主分支时,由于与跟踪的 gem 冲突,我必须将其删除]文件。
我想要的是类似 Gemfile.local
的东西,它将继承从 Gemfile
导入的 gem,但也允许导入新的 gem只能在我的机器上使用。此文件将在 .gitignore
中被忽略。这甚至可能吗?
设置BUNDLE_GEMFILE
环境变量:
BUNDLE_GEMFILE=Gemfile.local bundle exec rails c
仅在 Gemfile.local
中提供“增量”,将 require_relative 'Gemfile'
放在其顶部(或如@MichaelKohl 在评论中所建议的 Bundler::Dsl#eval_gemfile
。)
将下面的代码放在 Gemfile.local
的顶部以加载现有 gemfile
:
if File.exists?('Gemfile') then
eval File.read('Gemfile')
end
它将加载现有 Gemfile
中的所有 gem。您也可以根据需要添加新的宝石。
运行 下面的命令从新安装 gem Gemfile.local
:
bundle install --gemfile=Gemfile.local
我们的 git 存储库中目前有一个 Gemfile
。但是,有一个 gem 我只在我的环境中本地使用(我的团队不使用它)。为了使用它,我必须将它添加到我们的 Gemfile
,但每次我检查到我们的 master/dev 主分支时,由于与跟踪的 gem 冲突,我必须将其删除]文件。
我想要的是类似 Gemfile.local
的东西,它将继承从 Gemfile
导入的 gem,但也允许导入新的 gem只能在我的机器上使用。此文件将在 .gitignore
中被忽略。这甚至可能吗?
设置BUNDLE_GEMFILE
环境变量:
BUNDLE_GEMFILE=Gemfile.local bundle exec rails c
仅在 Gemfile.local
中提供“增量”,将 require_relative 'Gemfile'
放在其顶部(或如@MichaelKohl 在评论中所建议的 Bundler::Dsl#eval_gemfile
。)
将下面的代码放在 Gemfile.local
的顶部以加载现有 gemfile
:
if File.exists?('Gemfile') then
eval File.read('Gemfile')
end
它将加载现有 Gemfile
中的所有 gem。您也可以根据需要添加新的宝石。
运行 下面的命令从新安装 gem Gemfile.local
:
bundle install --gemfile=Gemfile.local