Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add option to prevent load of excluded groups #1648

Closed
wants to merge 2 commits into from

3 participants

@jreidinger

Hi,
even if I know that in bundler FAQ ability to require all spec for all groups is mentioned as feature it is not good behavior in some use cases.
One of them is our use case:
We develop virtual machine with requirement on minimal size dependency. We found bundler useful to handle multiple gem version in case, that there is more rails servers ( our server is just configuration server on specified port ). We ensure that version is correct different way, so we use bundler only to preload correct gem versions. We have quite a lot of gems in development and test groups, so for us is not option to have such gems on target system. Also we need to handle systems which is offline to public net, so downloading it is not option.

So what I change?
I add option miniresolver which solves only non-excluded groups. So if someone want on production miniresolving then creating .bundle/config which contain without and miniresolver, then it prevent loading of specs and resolve on required groups.

Thanks for attention
Josef

P.S. it would be nice if you can backport it also to 1.0 as we still use it ( change is same, just maybe testcase doesn't work, I can create separate sr if you are interested ).

@travisbot

This pull request fails (merged 3d33fa0 into 54b6240).

@indirect
Owner

Thank you for the pull request! Unfortunately, this sort of change is outside the scope of the Bundler project — we want to have a single resolve, including all groups, in the Gemfile.lock. If you remove any groups from the resolve, your resolve is no longer valid for the entire file, and that is no good. Have you tried putting the gem files into vendor/cache, or using the --deployment flag?

@indirect indirect closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  lib/bundler/definition.rb
@@ -31,6 +31,7 @@ def self.build(gemfile, lockfile, unlock)
def initialize(lockfile, dependencies, sources, unlock)
@dependencies, @sources, @unlock = dependencies, sources, unlock
+ @dependencies.reject!{ |d| (d.groups - Bundler.settings.without).empty?} if Bundler.settings[:miniresolver]
@remote = false
@specs = nil
@lockfile_contents = ""
View
3  man/bundle-config.ronn
@@ -71,6 +71,9 @@ learn more about their operation in [bundle install(1)][bundle-install].
is used.
* `without` (`BUNDLE_WITHOUT`):
A `:`-separated list of groups whose gems bundler should not install
+* `miniresolver (`BUNDLE_MINIRESOLVER`):
+ Resolve only over target groups, so for packages in excluded groups spec files not needed.
+ Defaults to `false`.
* `bin` (`BUNDLE_BIN`):
Install executables from gems in the bundle to the specified directory.
Defaults to `false`.
View
18 spec/runtime/setup_spec.rb
@@ -390,6 +390,24 @@
should_be_installed "activesupport 2.3.2", :groups => :default
end
+ it "doesn't need spec file of excluded group in miniresolver" do
+ install_gemfile <<-G, :without => :missing, :env => { "BUNDLE_MINIRESOLVER" => "true" }
+ source "file://#{gem_repo1}"
+ gem "activesupport"
+
+ group :rails do
+ gem "rails", "2.3.2"
+ end
+ group :missing do
+ gem "really_not_existing_gem"
+ end
+ G
+
+ install_gems "activesupport-2.3.5"
+
+ should_be_installed "activesupport 2.3.2", :groups => :default, :env => { "BUNDLE_MINIRESOLVER" => "true", "BUNDLE_WITHOUT" => "rails:missing" }
+ end
+
it "remembers --without and does not bail on bare Bundler.setup" do
install_gemfile <<-G, :without => :rails
source "file://#{gem_repo1}"
Something went wrong with that request. Please try again.