summaryrefslogtreecommitdiff
path: root/lib/bundler/runtime.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/runtime.rb')
-rw-r--r--lib/bundler/runtime.rb30
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 1225eb9f50..5280e72aa2 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -71,7 +71,7 @@ module Bundler
raise Bundler::GemRequireError.new e,
"There was an error while trying to load the gem '#{file}'."
end
- rescue RuntimeError => e
+ rescue StandardError => e
raise Bundler::GemRequireError.new e,
"There was an error while trying to load the gem '#{file}'."
end
@@ -130,11 +130,14 @@ module Bundler
specs_to_cache.each do |spec|
next if spec.name == "bundler"
- next if spec.source.is_a?(Source::Gemspec)
- if spec.source.respond_to?(:migrate_cache)
- spec.source.migrate_cache(custom_path, local: local)
- elsif spec.source.respond_to?(:cache)
- spec.source.cache(spec, custom_path)
+
+ source = spec.source
+ next if source.is_a?(Source::Gemspec)
+
+ if source.respond_to?(:migrate_cache)
+ source.migrate_cache(custom_path, local: local)
+ elsif source.respond_to?(:cache)
+ source.cache(spec, custom_path)
end
end
@@ -171,7 +174,14 @@ module Bundler
spec_cache_paths = []
spec_gemspec_paths = []
spec_extension_paths = []
- Bundler.rubygems.add_default_gems_to(specs).values.each do |spec|
+ specs_to_keep = Bundler.rubygems.add_default_gems_to(specs).values
+
+ current_bundler = Bundler.rubygems.find_bundler(Bundler.gem_version)
+ if current_bundler
+ specs_to_keep << current_bundler
+ end
+
+ specs_to_keep.each do |spec|
spec_gem_paths << spec.full_gem_path
# need to check here in case gems are nested like for the rails git repo
md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
@@ -237,7 +247,11 @@ module Bundler
cached.each do |path|
Bundler.ui.info " * #{File.basename(path)}"
- File.delete(path)
+
+ begin
+ File.delete(path)
+ rescue Errno::ENOENT
+ end
end
end
end