lib/bundler/rubygems_integration.rb in bundler-2.2.0.rc.1 vs lib/bundler/rubygems_integration.rb in bundler-2.2.0.rc.2

- old
+ new

@@ -311,12 +311,17 @@ if spec = specs_by_name[dep.name] return true if dep.matches_spec?(spec) end message = if spec.nil? + target_file = begin + Bundler.default_gemfile.basename + rescue GemfileNotFound + "inline Gemfile" + end "#{dep.name} is not part of the bundle." \ - " Add it to your #{Bundler.default_gemfile.basename}." + " Add it to your #{target_file}." else "can't activate #{dep}, already activated #{spec.full_name}. " \ "Make sure all dependencies are added to Gemfile." end @@ -404,10 +409,21 @@ end # Replace or hook into RubyGems to provide a bundlerized view # of the world. def replace_entrypoints(specs) + specs_by_name = add_default_gems_to(specs) + + replace_gem(specs, specs_by_name) + stub_rubygems(specs) + replace_bin_path(specs_by_name) + + Gem.clear_paths + end + + # Add default gems not already present in specs, and return them as a hash. + def add_default_gems_to(specs) specs_by_name = specs.reduce({}) do |h, s| h[s.name] = s h end @@ -418,14 +434,10 @@ specs << default_spec specs_by_name[default_spec_name] = default_spec end - replace_gem(specs, specs_by_name) - stub_rubygems(specs) - replace_bin_path(specs_by_name) - - Gem.clear_paths + specs_by_name end def undo_replacements @replaced_methods.each do |(sym, klass), method| redefine_method(klass, sym, method)