Skip to content

Commit

Permalink
Cached gem path resolution should consider default gems
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Oct 21, 2021
1 parent 8fe74a7 commit 83b2b84
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions bundler/lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def install(spec, opts = {})
Bundler.ui.confirm message

path = cached_gem(spec)
raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
if requires_sudo?
install_path = Bundler.tmp(spec.full_name)
bin_path = install_path.join("bin")
Expand Down Expand Up @@ -233,11 +234,7 @@ def install(spec, opts = {})
end

def cache(spec, custom_path = nil)
if spec.default_gem?
cached_path = cached_built_in_gem(spec)
else
cached_path = cached_gem(spec)
end
cached_path = cached_gem(spec)
raise GemNotFound, "Missing gem file '#{spec.file_name}'." unless cached_path
return if File.dirname(cached_path) == Bundler.app_cache.to_s
Bundler.ui.info " * #{File.basename(cached_path)}"
Expand Down Expand Up @@ -352,11 +349,11 @@ def loaded_from(spec)
end

def cached_gem(spec)
cached_gem = cached_path(spec)
unless cached_gem
raise Bundler::GemNotFound, "Could not find #{spec.file_name} for installation"
if spec.default_gem?
cached_built_in_gem(spec)
else
cached_path(spec)
end
cached_gem
end

def cached_path(spec)
Expand Down

0 comments on commit 83b2b84

Please sign in to comment.