Gemfile-将生产宝石与开发宝石分离 [英] Gemfile - separating Production gems from Development gems

查看:87
本文介绍了Gemfile-将生产宝石与开发宝石分离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我知道在Gemfile中我可以执行以下操作:

So I know that in a Gemfile I can do something like this:

group :development, :test do
  gem 'gem1'
  gem 'gem2'
end

我做什么我想要完成的事情是这样的:

What I am looking to accomplish is something like this:

group :production do
  gem 'gem1'
  gem 'gem2'
end

group :development, :test do
  gem 'gem1', :path => '/Documents/Code/gem1/'
  gem 'gem2', :path => '/Documents/Code/gem2/'
end

因此我们的应用程序使用2个gem我们也在本地发展。为了缩短在本地计算机上进行开发的时间,我们希望能够将我们的开发环境指向gem的本地副本-这样,它可以提取所有更改而无需重新启动rails服务器。否则,我们将不得不重新构建gem,重新安装gem,并随着gem中的每个开发更改重新启动rails。

So our application uses 2 gems that we also develop locally. In order to improve time while developing on our local machines, we want to be able to point our dev environments to the local copies of the gems - this way it picks up all changes without needing to restart our rails server. Otherwise we would have to rebuild the gem, re-install the gem, and restart rails with every development change in the gem.

但是,这样做会给我以下错误:

However, doing this gives me the following error:

You cannot specify the same gem twice coming from different sources. You specified that gem1 (>= 0) should come from an unspecfied source and source at /Documents/Code/gem1

我什至尝试运行类似 bundle install的东西-没有生产 c,但是我遇到了同样的错误。

I have tried even running something like bundle install --without production and I get the same error.

有人知道我是否可以做我想做的事?

Does anyone know if it IS possible to do what I would like to do?

谢谢!

推荐答案

我认为有一种受支持的方式可以做到这一点,并且有一些黑客可以解决。

i think that there is a supported way to do it and some hacks to work around it.

受支持的方式:

使用 bundle配置 local 选项,如下所述:< a href = http://bundler.io/v1.3/man/bundle-config.1.html rel = nofollow> http://bundler.io/v1.3/man/bundle-config。 1.html

use bundle config with the local option as described here: http://bundler.io/v1.3/man/bundle-config.1.html

hacky方式:

在生产环境中使用之前使用env vars和执行bundler : http:// www .cowboycoded.com / 2010/08/10 / using-2-sources-for-a-gem-in-gem-environments-with-bundler /

use env vars and execute bundler before using in production: http://www.cowboycoded.com/2010/08/10/using-2-sources-for-a-gem-in-different-environments-with-bundler/

在github上有一个针对此问题的功能请求,其中包含一些相关问题和大量注释: https ://github.com/carlhuda/bundler/issues/396

there is a feature-request for this problem on github with several related issues and lots of comments: https://github.com/carlhuda/bundler/issues/396

这篇关于Gemfile-将生产宝石与开发宝石分离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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