def install(spec)
if installed_specs[spec].any?
Bundler.ui.info "Using #{spec.name} (#{spec.version}) "
return
end
Bundler.ui.info "Installing #{spec.name} (#{spec.version}) "
path = cached_gem(spec)
Bundler.rubygems.preserve_paths do
install_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir
options = { :install_dir => install_path,
:ignore_dependencies => true,
:wrappers => true,
:env_shebang => true }
options.merge!(:bin_dir => "#{install_path}/bin") unless spec.executables.nil? || spec.executables.empty?
installer = Bundler::GemInstaller.new path, options
installer.install
end
if Bundler.requires_sudo?
sudo "mkdir -p #{Bundler.rubygems.gem_dir}/gems #{Bundler.rubygems.gem_dir}/specifications"
sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Bundler.rubygems.gem_dir}/gems/"
sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Bundler.rubygems.gem_dir}/specifications/"
spec.executables.each do |exe|
sudo "mkdir -p #{Bundler.rubygems.gem_bindir}"
sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.rubygems.gem_bindir}"
end
end
spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
end