Permalink
Browse files

cache command should not prune gems for other platforms

  • Loading branch information...
1 parent 391a888 commit e13dd685aea0f150a1690710636be0e7b19d4014 @indirect indirect committed Apr 21, 2010
Showing with 19 additions and 0 deletions.
  1. +1 −0 lib/bundler/runtime.rb
  2. +18 −0 spec/cache/gems_spec.rb
View
1 lib/bundler/runtime.rb
@@ -99,6 +99,7 @@ def prune_cache
Bundler.ui.info "Removing outdated .gem files from vendor/cache"
cache_path.children.each do |gem_path|
cached_spec = Gem::Format.from_file_by_path(gem_path).spec
+ next unless cached_spec.platform =~ Gem::Platform.local
@menno
menno added a line comment Apr 21, 2010

This prevents pruning cached gems on my machine (Mac Snow Leopard / bundled ruby 1.8.7).

The check fails because for all cached gems 'cached_spec.platform' is 'ruby' and Gem::Platform.local is 'universal-darwin-10'

@indirect
Bundler member
indirect added a line comment Apr 21, 2010

Yeah, you're totally right. I've fixed this for 0.9.24 by switching to Gem::Platform.match(cached_spec.platform).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
unless specs.any?{|s| s.full_name == cached_spec.full_name }
Bundler.ui.info " * #{File.basename(gem_path)}"
gem_path.rmtree
View
18 spec/cache/gems_spec.rb
@@ -116,6 +116,24 @@
cached_gem("activesupport-2.3.2").should_not exist
end
+ it "doesn't remove gems that are for another platform" do
+ install_gemfile <<-G
+ Gem.platforms = [#{java}]
+ source "file://#{gem_repo1}"
+ gem "platform_specific"
+ G
+ bundle :cache
+ cached_gem("platform_specific-1.0-java").should exist
+
+ simulate_new_machine
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "platform_specific"
+ G
+ cached_gem("platform_specific-1.0-#{Gem::Platform.local}").should exist
+ cached_gem("platform_specific-1.0-java").should exist
+ end
+
it "doesn't remove gems with mismatched :rubygems_version or :date" do
cached_gem("rack-1.0.0").rmtree
build_gem "rack", "1.0.0",

0 comments on commit e13dd68

Please sign in to comment.