是否可以覆盖gemfile进行本地开发? [英] Is it possible to override gemfile for local development?

查看:94
本文介绍了是否可以覆盖gemfile进行本地开发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的git仓库中目前有一个Gemfile.但是,有一个gem我只能在我的环境中本地使用(我的团队不使用它).为了使用它,我必须将其添加到我们的Gemfile中,但是每次我检出到master/dev主分支时,由于与跟踪的gemfile冲突,我都必须将其删除.

We have a Gemfile currently in our git repository. However, there's a gem I use only locally in my environment (my team doesn't use it). In order to use it, I have to add it to our Gemfile, but every time I check out to our master/dev main branch, I have to remove it because of conflicts with the tracked gemfile.

我想要的是类似Gemfile.local的东西,它将继承从Gemfile导入的宝石,但也允许将新的宝石导入那里,仅在我的机器上使用.此文件在.gitignore中将被忽略.这有可能吗?

What I would like is something like a Gemfile.local which would inherit the gems imported from the Gemfile but to also allow new gems to be imported there to use on my machine only. This file would be ignored in .gitignore. Is this even possible?

推荐答案

设置BUNDLE_GEMFILE环境变量:

BUNDLE_GEMFILE=Gemfile.local bundle exec rails c


仅在Gemfile.local中提供一个增量",在其顶部放置require_relative 'Gemfile'(或@MichaelKohl在评论中建议的Bundler::Dsl#eval_gemfile).


To provide a "delta" only in the Gemfile.local put require_relative 'Gemfile' on top of it (or Bundler::Dsl#eval_gemfile as suggested by @MichaelKohl in comments.)

这篇关于是否可以覆盖gemfile进行本地开发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆