diff options
-rw-r--r-- | lib/bundler/runtime.rb | 8 | ||||
-rw-r--r-- | spec/commands/package_spec.rb | 44 |
2 files changed, 52 insertions, 0 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 63e345b04b..e2ee46ac8c 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -115,8 +115,16 @@ module Bundler end unless File.exist?(cache_path) Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}" + + # Do not try to cache specification for the gem described by the .gemspec + root_gem_name = nil + if gemspec_cache_hash = Bundler.instance_variable_get(:@gemspec_cache) + gemspec = gemspec_cache_hash.values.first + root_gem_name = gemspec.name unless gemspec.nil? + end specs.each do |spec| next if spec.name == "bundler" + next if File.exist?("#{root_gem_name}.gemspec") && spec.source.class == Bundler::Source::Path && root_gem_name && spec.name == root_gem_name spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true) spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache) end diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb index 9861f4c21e..f9be542f60 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/package_spec.rb @@ -15,6 +15,50 @@ describe "bundle package" do end end + context "with --all" do + context "without a gemspec" do + it "caches all dependencies except bundler itself" do + gemfile <<-D + source "file://#{gem_repo1}" + gem 'rack' + gem 'bundler' + D + + bundle "package --all" + + expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist + expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist + end + end + context "with a gemspec" do + before do + File.open(bundled_app("mygem.gemspec"), "w") do |f| + f.write <<-G + Gem::Specification.new do |s| + s.name = "mygem" + s.version = "0.1.1" + s.add_development_dependency "nokogiri", "=1.4.2" + end + G + end + end + it "caches all dependencies except bundler and the gemspec specified gem" do + gemfile <<-D + source "file://#{gem_repo1}" + gem 'rack' + gemspec + D + + bundle "package --all" + sleep 20 + expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist + expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist + expect(bundled_app("vendor/cache/mygem-0.1.1.gem")).to_not exist + expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist + end + end + end + context "with --path" do it "sets root directory for gems" do gemfile <<-D |