Ruby Bundler Gemfile中的多个来源 [英] Ruby Bundler multiple sources in Gemfile

查看:65
本文介绍了Ruby Bundler Gemfile中的多个来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要确保某些宝石是从我们自己的宝石库而不是rubygems安装的,而其余宝石是从rubygems安装的。我可以在Gemfile中进行设置,而不必担心与Rubygems中的同名gem发生命名冲突吗?如何确定从何处下载gem?

I need to ensure some of my gems are installed from our own gem repository rather than rubygems, while the rest are installed from rubygems. Can I set this up in the Gemfile without worrying about a naming conflict with a identically named gem in Rubygems? How Can I determine where the gem is downloaded from?

例如
Gemfile:

eg Gemfile:

source :rubygems  
gem 'gemfromrubygems1'  
gem 'gemfromrubygems2'

source "http://our.own.gem.repo.com/the/path/to/it"  
gem 'gemfromourrepo'


推荐答案

Bundler 1.7具有一项新功能,可让您通过将特定宝石嵌套在一个块中来选择其来源:

Bundler 1.7 has a new feature that allows you to select the source for specific gems by nesting them in a block:

source "https://rubygems.org"

gem 'gemfromrubygems1' 
gem 'gemfromrubygems2'

source "http://our.own.gem.repo.com/the/path/to/it" do
  gem 'gemfromourrepo'
end

或将其指定为选项:

source "https://rubygems.org"

gem 'gemfromrubygems1' 
gem 'gemfromrubygems2'

gem 'gemfromourrepo', source: "http://our.own.gem.repo.com/the/path/to/it"

请参见 http://bundler.io/v1.7/gemfile.html 了解详情。

这篇关于Ruby Bundler Gemfile中的多个来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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