diff options
-rw-r--r-- | lib/bundler/runtime.rb | 7 | ||||
-rw-r--r-- | spec/cache/platform_spec.rb | 41 | ||||
-rw-r--r-- | spec/support/helpers.rb | 13 |
3 files changed, 58 insertions, 3 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 99f72bc7d2..efcee1c5b6 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -85,11 +85,12 @@ module Bundler def prune_cache FileUtils.mkdir_p(cache_path) + resolve = @definition.resolve + Bundler.ui.info "Removing outdated .gem files from vendor/cache" Pathname.glob(cache_path.join("*.gem").to_s).each do |gem_path| - cached_spec = Gem::Format.from_file_by_path(gem_path).spec - next unless Gem::Platform.match(cached_spec.platform) - unless specs.any?{|s| s.full_name == cached_spec.full_name } + cached = Gem::Format.from_file_by_path(gem_path).spec + unless resolve.any?{|s| s.name == cached.name && s.version == cached.version } Bundler.ui.info " * #{File.basename(gem_path)}" gem_path.rmtree end diff --git a/spec/cache/platform_spec.rb b/spec/cache/platform_spec.rb new file mode 100644 index 0000000000..d665c92070 --- /dev/null +++ b/spec/cache/platform_spec.rb @@ -0,0 +1,41 @@ +require "spec_helper" + +describe "bundle cache with multiple platforms" do + before :each do + gemfile <<-G + source "file://#{gem_repo1}" + + platforms :ruby do + gem "rack", "1.0.0" + end + + platforms :jruby do + gem "activesupport", "2.3.5" + end + G + + lockfile <<-G + GEM + remote: file:#{gem_repo1}/ + specs: + rack (1.0.0) + activesupport (2.3.5) + + PLATFORMS + ruby + java + + DEPENDENCIES + rack (1.0.0) + activesupport (2.3.5) + G + end + + it "does not delete gems for other platforms" do + cache_gems "rack-1.0.0", "activesupport-2.3.5" + bundle "install" + + bundled_app("vendor/cache/rack-1.0.0.gem").should exist + bundled_app("vendor/cache/activesupport-2.3.5.gem").should exist + end +end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 57b62710bc..ab60a6381f 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -179,6 +179,19 @@ module Spec end end + def cache_gems(*gems) + gems = gems.flatten + + FileUtils.rm_rf("#{bundled_app}/vendor/cache") + FileUtils.mkdir_p("#{bundled_app}/vendor/cache") + + gems.each do |g| + path = "#{gem_repo1}/gems/#{g}.gem" + raise "OMG `#{path}` does not exist!" unless File.exist?(path) + FileUtils.cp(path, "#{bundled_app}/vendor/cache") + end + end + def simulate_new_machine system_gems [] FileUtils.rm_rf default_bundle_path |