def install_gem_from_cache(gem, options = {})
version = options.delete(:version)
Gem.configuration.update_sources = false
installer = Gem::DependencyInstaller.new(options.merge(:user_install => false))
exception = nil
begin
if gem_file = find_gem_in_cache(gem, version)
puts "Located #{gem} in gem cache..."
installer.install gem_file
else
raise Gem::InstallError, "Unknown gem #{gem}"
end
rescue Gem::InstallError => e
exception = e
end
if installer.installed_gems.empty? && exception
error "Failed to install gem '#{gem}' (#{e.message})"
end
ensure_bin_wrapper_for_installed_gems(installer.installed_gems, options)
installer.installed_gems.each do |spec|
success "Successfully installed #{spec.full_name}"
end
end