Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
cache command no longer prunes gems built with older rubygems versions
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Apr 21, 2010
1 parent a5ecbe1 commit 7c9e331
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def check
method_option "relock", :type => :boolean, :banner => "Unlock, install the gems, and relock."
method_option "disable-shared-gems", :type => :boolean, :banner => "Do not use any shared gems, such as the system gem repository."
method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
def install(path = nil)
opts = options.dup
opts[:without] ||= []
Expand All @@ -91,11 +92,11 @@ def install(path = nil)
raise GemfileChanged, "You changed your Gemfile after locking. " +
"Please run `bundle install --relock`."
end
Bundler.ui.confirm "Your bundle is complete! " +
"Use `bundle show [gemname]` to see where a bundled gem is installed."

lock if options[:relock]
cache if Bundler.root.join("vendor/cache").exist?
Bundler.ui.confirm "Your bundle is complete! " +
"Use `bundle show [gemname]` to see where a bundled gem is installed."
rescue GemNotFound => e
if Bundler.definition.sources.empty?
Bundler.ui.warn "Your Gemfile doesn't have any sources. You can add one with a line like 'source :gemcutter'"
Expand Down
11 changes: 11 additions & 0 deletions spec/cache/gems_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@
cached_gem("actionpack-2.3.2").should_not exist
cached_gem("activesupport-2.3.2").should_not 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",
:path => bundled_app('vendor/cache'),
:rubygems_version => "1.3.2"
simulate_new_machine

bundle :install
cached_gem("rack-1.0.0").should exist
end
end

end
8 changes: 8 additions & 0 deletions spec/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ def add_c_extension

def _build(options)
path = options[:path] || _default_path

if options[:rubygems_version]
@spec.rubygems_version = options[:rubygems_version]
def @spec.mark_version; end
def @spec.validate; end
end

case options[:gemspec]
when false
# do nothing
Expand All @@ -381,6 +388,7 @@ def _build(options)
unless options[:no_default]
@files = _default_files.merge(@files)
end

@files.each do |file, source|
file = Pathname.new(path).join(file)
FileUtils.mkdir_p(file.dirname)
Expand Down

0 comments on commit 7c9e331

Please sign in to comment.