捆绑器忽略 'without' 组
Bundler ignoring 'without' group
我正在尝试在开发中包含来自本地而不是 gemserver 的 gem。我的 Gemfile 如下所示:
group :development do
gem "appy_core", path: "../engines/core"
end
group :production do
gem "appy_core", '1.7.4.5'
end
我的 .bundle/config
设置为:
---
BUNDLE_WITHOUT: production
然而当我 运行 bundle
我得到:
[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements.
You specified: appy_core (>= 0) and appy_core (= 1.7.4.5). Bundler cannot continue.
运行 bundle install --without production
产生相同的结果。
我想到/知道的唯一解决方案:
在Gemfile
中:
gem 'appy_core',
git: 'git://github.com/.......',
branch: '1.7.4.5' # put the name of the branch that corresponds
在本地环境的shell:
$ bundle config local.appy_core /path/to/engines/core
现在在本地分支做任何你想做的事,在本地提交并享受。
有效的技巧
由于 Gemfile
是普通的 ruby,因此可以在那里使用 ruby 功能:
永久性 shell 设置中的某处:
alias bundle="USE_DEV_VERSION=1 bundle"
在Gemfile
中:
if ENV['USE_DEV_VERSION']
gem "appy_core", path: "../engines/core"
else
gem "appy_core", '1.7.4.5'
end
现在 bundle install
将在本地使用开发版本,在“修补”环境之外使用标准 gem。
由于 Gemfile
作为 Ruby 代码执行,您可以直接引用 Bundler.settings
以明确排除组中的重复 gem:
def without?(group)
Bundler.settings.without.include?(group)
end
group :development do
gem "appy_core", path: "../engines/core" unless without? :development
end
group :production do
gem "appy_core", '1.7.4.5' unless without? :production
end
我正在尝试在开发中包含来自本地而不是 gemserver 的 gem。我的 Gemfile 如下所示:
group :development do
gem "appy_core", path: "../engines/core"
end
group :production do
gem "appy_core", '1.7.4.5'
end
我的 .bundle/config
设置为:
---
BUNDLE_WITHOUT: production
然而当我 运行 bundle
我得到:
[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements.
You specified: appy_core (>= 0) and appy_core (= 1.7.4.5). Bundler cannot continue.
运行 bundle install --without production
产生相同的结果。
我想到/知道的唯一解决方案:
在Gemfile
中:
gem 'appy_core',
git: 'git://github.com/.......',
branch: '1.7.4.5' # put the name of the branch that corresponds
在本地环境的shell:
$ bundle config local.appy_core /path/to/engines/core
现在在本地分支做任何你想做的事,在本地提交并享受。
有效的技巧
由于 Gemfile
是普通的 ruby,因此可以在那里使用 ruby 功能:
永久性 shell 设置中的某处:
alias bundle="USE_DEV_VERSION=1 bundle"
在Gemfile
中:
if ENV['USE_DEV_VERSION']
gem "appy_core", path: "../engines/core"
else
gem "appy_core", '1.7.4.5'
end
现在 bundle install
将在本地使用开发版本,在“修补”环境之外使用标准 gem。
由于 Gemfile
作为 Ruby 代码执行,您可以直接引用 Bundler.settings
以明确排除组中的重复 gem:
def without?(group)
Bundler.settings.without.include?(group)
end
group :development do
gem "appy_core", path: "../engines/core" unless without? :development
end
group :production do
gem "appy_core", '1.7.4.5' unless without? :production
end