method
install
v1_9_3_125 -
Show latest stable
- Class:
Gem::Installer
install()public
Installs the gem and returns a loaded Gem::Specification for the installed gem.
The gem will be installed with the following structure:
@gem_home/ cache/<gem-version>.gem #=> a cached copy of the installed gem gems/<gem-version>/... #=> extracted files specifications/<gem-version>.gemspec #=> the Gem::Specification
# File lib/rubygems/installer.rb, line 143
def install
current_home = Gem.dir
current_path = Gem.paths.path
verify_gem_home(options[:unpack])
Gem.use_paths gem_home, current_path # HACK: shouldn't need Gem.paths.path
# If we're forcing the install then disable security unless the security
# policy says that we only install signed gems.
@security_policy = nil if @force and @security_policy and
not @security_policy.only_signed
unless @force
ensure_required_ruby_version_met
ensure_required_rubygems_version_met
ensure_dependencies_met unless @ignore_dependencies
end
Gem.pre_install_hooks.each do |hook|
result = hook.call self
if result == false then
location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
message = "pre-install hook#{location} failed for #{spec.full_name}"
raise Gem::InstallError, message
end
end
Gem.ensure_gem_subdirectories gem_home
# Completely remove any previous gem files
FileUtils.rm_rf(gem_dir) if File.exist? gem_dir
FileUtils.mkdir_p gem_dir
extract_files
build_extensions
Gem.post_build_hooks.each do |hook|
result = hook.call self
if result == false then
FileUtils.rm_rf gem_dir
location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
message = "post-build hook#{location} failed for #{spec.full_name}"
raise Gem::InstallError, message
end
end
generate_bin
write_spec
write_require_paths_file_if_needed if Gem::QUICKLOADER_SUCKAGE
cache_file = spec.cache_file
FileUtils.cp gem, cache_file unless File.exist? cache_file
say spec.post_install_message unless spec.post_install_message.nil?
spec.loaded_from = spec.spec_file
Gem::Specification.add_spec spec unless Gem::Specification.include? spec
Gem.post_install_hooks.each do |hook|
hook.call self
end
return spec
rescue Zlib::GzipFile::Error
raise Gem::InstallError, "gzip error installing #{gem}"
ensure
# conditional since we might be here because we're erroring out early.
if current_path
Gem.use_paths current_home, current_path
end
end Related methods
- Instance methods
- app_script_text
- build_extensions
- check_that_user_bin_dir_is_in_path
- dir
- ensure_dependencies_met
- ensure_dependency
- ensure_required_ruby_version_met
- ensure_required_rubygems_version_met
- extract_files
- format
- formatted_program_filename
- gem_dir
- generate_bin
- generate_bin_script
- generate_bin_symlink
- generate_windows_script
- install
- installation_satisfies_dependency?
- process_options
- shebang
- spec
- unpack
- verify_gem_home
- windows_stub_script
- write_spec
- Class methods
- exec_format
- new